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
Manoj Swami -
Yuhao Chen -
James Carter -
Bobby Iliev -
Top comments (0)