Does this query work? Normally I see an as with a count like:
count(client_id) as total // or something
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can you interpret this mysql query into eloquent orm form or into a query builder: select count(client_id), client_id from bookings group by client_id order by count(client_id) desc;
I'm going to retrieve 'client_id' with most entries on the table. I can't seem to figure it myself, so i'm reaching out to you guys. Thanks!
OK, did you see in the querybuilder the raw expression example:
$users = DB::table('users')
->select(DB::raw('count(*) as user_count, status'))
->where('status', '<>', 1)
->groupBy('status')
->get();
Have you tried with using raw?
Please or to participate in this conversation.