Answer the question
In order to leave comments, you need to log in
How to properly write using query builder laravel?
How to rewrite this query using query builder in laravel?
SELECT count(public.events.is_hit) as is_hit, event_date
FROM public.events group by is_hit, event_date order by is_hit desc;
$query->groupBy('is_hit');
$query->groupBy('event_date');
$query->orderBy('is_hit', $sorting['desc']);
Answer the question
In order to leave comments, you need to log in
https://laravel.com/docs/8.x/queries#raw-expressions
something like DB::table('public.events')->select('event_date', DB::raw('count( is_hit) as is_hit'))->groupBy('is_hit', 'event_date')->orderBy('is_hit', $sorting['desc'])->get()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question