In laravel 5.2, I want to get users by order country
, then posts_count
and then images_count
. For that I have used below query.
User::with(['profiles' => function($query) use ($country){
$query->orderBy(DB::raw('case when country="'.$country.'" then 1 else 2 end'))->orderBy('country', 'ASC');
}])
->withCount('posts')
->withCount('images')
->orderBy('posts_count', 'desc')
->orderBy('images_count', 'desc')
->get();
But this query sort users by posts_count
, then images_count
and then country
. Please guide how can I fix the order priority country
first in the query.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2s5Mvlt
via IFTTT
Aucun commentaire:
Enregistrer un commentaire