Ha guys,
I am currently learning Eloquent but I am having trouble forming my query properly.
What I want to archieve is:
Get ALL results but group on "url" and count each value togather from "page_load_time" and "pagespeed_score" field.
So basicly I have this date:
1 0.214 9.2 xxx.it/mypage/
2 0.321 8.9 xxx.it/mypage/
and it should become this:
1 0.535 18.1 xxx.it/mypage/
My current query is:
$data = Rapports::select('id', DB::raw('SUM(page_load_time) as pltt'), 'uri', DB::raw('SUM(pagespeed_score) as pst'), 'execution_date')
->orderBy('id', 'desc')
->where('execution_date', '>=', date("Y", time()).'-'.date("m", time()).'-01')
->whereIn('uri', $arr)
->groupBy('uri')
->get();
Besides that, I cannot use groupBy without pasting in ALL my fields but I only want to group on "url" and not everything (which isnt working anyways lol).
In normal SQL I just write "GROUP BY url" and thats it, all results are grouped. But Laravel 5.4 gives me an error when I do this and forces me to enter ALL row names into the groupBy.
Hope someone can give me the right answer :)
Your sincerely,
Mithradantor