1$docs = Document::groupBy('users_editor_id')
2 ->selectRaw('sum(no_of_pages) as sum, users_editor_id')
3 ->get(); //this return collection
4
5//In Blade
6@foreach($docs as $doc)
7 {{$doc->users_editor_id}} >-------< {{$doc->sum}}
8@endforeach
1Document::groupBy('users_editor_id')
2 ->selectRaw('sum(no_of_pages) as sum, users_editor_id')
3 ->pluck('sum','users_editor_id');
4
5 // originally lists(), which was deprecated in favour of pluck in 5.2
6 // and dropped completely in 5.3
7 // ->lists('sum','users_editor_id');
8
9
10// returns array like this:
11array(
12 users_editor_id => sum,
13 ...
14)