my code is as followed:
return User::whereHas('roles', function ($role, $query) {
return $role;
$query->whereId($role);
})->get();
what I am trying is to pass role id here to query builder.
it ends up with following error:
Symfony\Component\Debug\Exception\FatalThrowableError
Too few arguments to function App\Http\Controllers\UserController::App\Http\Controllers\{closure}(), 1 passed in /Users/x/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php on line 962 and exactly 2 expected