Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

in sql query you can use count() aggregate and order by that column

select count(link_id)
from link_user
order by count(link_id) desc

not sure how to do it using eloquent but you can try this

return DB::table('link_user')
->select(DB::raw('count(link_id)')
->orderBy(DB::raw('count(link_id)')
->get();
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.