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();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community