Laravel 5.4: How to order by count (column) eloquent?
4 answers
I think you can try this:
$all = Report::where('state', '=', 'Assigned')
->select(DB::raw('count(reports.assigned_to) as assigned_to'),DB::raw('count(access.assigned_to) as assigned_to_access'))
->leftjoin('access','report.access.id','=','access.id')
->union($accesses)
->orderBy('assigned_to','DESC')
->orderBy('assigned_to_access','DESC')
->get();
Hope this help for you.
0
source to share