Sortuj według liczby widoków schodzących z laravel
$posts = Post::select(DB::raw('posts.*, count(*) as `aggregate`'))
->join('views', 'posts.id', '=', 'views.post_id')
->groupBy('post_id')
->orderBy('aggregate', 'desc')
->get();
SimonAngatia