User::query() in laravel code example
Example 1: laravel where
$users = DB::table('users')
->whereMonth('created_at', '12')
->get();
Example 2: when in larevel
$role = $request->input('role');
$users = DB::table('users')
->when($role, function ($query, $role) {
return $query->where('role_id', $role);
})
->get();