I have musics_rate table and musics table:
musics_rate:
music_id : integer
user_id : integer
rate_type : boolean
Music model:
public function rates()
{
return $this->belongsToMany(User::class, 'musics_rate');
}
Now i want to sort musics by music_rates(rate_type==true
) count (created in this weak):
Music::where('created_at','>=', Carbon::parse('last saturday'))
->withCount('rates')
->orderby('rates_count','desc')
->get();
But it sort by all rates(positive rates and negative rates) count.
Is there any way to filter positive rates just?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JiEnaU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire