Multiple Collection Methods in a Row in Laravel
If you query all results with ->all() or ->get(), you may then perform various Collection operations on the same result, it won’t query database every time.
$users = User::all(); echo 'Max ID: ' . $users->max('id'); echo 'Average age: ' . $users->avg('age'); echo 'Total budget: ' . $users->sum('budget');