📅  最后修改于: 2022-03-11 14:54:12.735000             🧑  作者: Mango
$role = $request->input('role');
$users = DB::table('users')
->when($role, function ($query, $role) {
return $query->where('role_id', $role);
})
->get();