📅  最后修改于: 2022-03-11 14:53:47.030000             🧑  作者: Mango
$users = User::withCount([
'posts',
'comments',
'comments as approved_comments_count' => function ($query) {
$query->where('approved', 1);
}
])->get();