📅  最后修改于: 2022-03-11 14:54:05.825000             🧑  作者: Mango
DB::table('users')
->select('users.*', DB::raw('count(orders.user_id) as count_by_user_id'))
->join('orders' ,function($join){
$join->on('orders.user_id', '=', 'users.id');
})
->groupBy('users.id')
->orderBy('users.id', "DESC")
->get();