I was trying to use groupBy for grouping all views by uni_id and their date of creation so I can generate reports. But I see Laravel Eloquent is generating error. However when I executed the same query in phpmyadmin, it shows me data. How does Eloquent process its queries?
I am using Laravel 5.2
This is the query I am trying to run through Eloquent:
$data = UniversityView::
groupBy('created_at', 'uni_id')
->select('uni_id', DB::raw('count(*) as views'), 'name', 'created_at')
->get();
The question is not how to fix it. I fixed it already by putting 'name' in groupBy. But the question is why query is executing differently through Eloquent?
Check images below for help. Thanks.

