📅  最后修改于: 2022-03-11 14:54:26.331000             🧑  作者: Mango
$posts = Post::select(DB::raw('posts.*, count(*) as `aggregate`'))
->join('views', 'posts.id', '=', 'views.post_id')
->groupBy('post_id')
->orderBy('aggregate', 'desc')
->get();