TIL: Apart from withCount, eloquent also have other aggregate functions like withMax, withMin, withAvg and withSum.
Eg:
$posts = Post::withSum('comments', 'votes')->get();
foreach ($posts as $post) {
echo $post->comments_sum_votes;
}
TIL: Apart from withCount, eloquent also have other aggregate functions like withMax, withMin, withAvg and withSum.
Eg:
$posts = Post::withSum('comments', 'votes')->get();
foreach ($posts as $post) {
echo $post->comments_sum_votes;
}
For further actions, you may consider blocking this person and/or reporting abuse
Martins Onuoha -
Emmanuel C. Okolie -
Iwobi Okwudili Frank -
boolfalse -
Top comments (0)