Reputation: 35
I'm facing a problem when trying to order after using groupBy I wanna sort the grouped entries but its not working here is what I was trying to do
$errors = UserErrors::all()->groupBy('user_id')->orderBy('id');
Upvotes: 1
Views: 679
Reputation: 4459
$errors = UserErrors::groupBy('feild_name')->orderBy('feild_name','DESC')->get();
Example as below
$query->where('feild_name', '=', 'active')
->groupBy('feild_name')
->orderBy('date','DESC')
->get();
Upvotes: 1