Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel sum group by

$docs = Document::groupBy('users_editor_id')
   ->selectRaw('sum(no_of_pages) as sum, users_editor_id')
   ->get(); //this return collection 

//In Blade
@foreach($docs as $doc)
	{{$doc->users_editor_id}} >-------< {{$doc->sum}}
@endforeach
 
PREVIOUS NEXT
Tagged: #laravel #sum #group
ADD COMMENT
Topic
Name
4+3 =