📜  laravel 按日期分组计数 - PHP 代码示例

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

代码示例1
$usersData = User::select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as total'))
            ->groupBy('date')
            ->orderBy('date', 'desc')
            ->take(7)
            ->get();