📜  withCount laravel 分配通用名称 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:47.030000             🧑  作者: Mango

代码示例1
$users = User::withCount([
    'posts', 
    'comments', 
    'comments as approved_comments_count' => function ($query) {
        $query->where('approved', 1);
    }
])->get();