Level 122
share the error? you can share the error publicly via a link on the error page
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have this middleware
class CheckRole
{
public function handle(Request $request, Closure $next, string $section, mixed $roles): mixed
{
$userRoles = $request->user()->getAllRoles();
if ($userRoles['panel']['full_perm'] == 1 || (isset($userRoles[$section]['full_perm']) && $userRoles[$section]['full_perm'] == 1)) {
return $next($request);
}
$storedRoles = [];
foreach ($roles as $role) {
if (in_array($role, $userRoles[$section] ?? [])) {
$storedRoles[] = $role;
}
}
if (array_diff($roles, $storedRoles)) {
return redirect()->back()->withErrors('You do not have permission to preform this action');
}
return $next($request);
}
}
and i have theese routes in web
Route::middleware('role:panel,full_perm')->prefix('users')->group(function () {
Route::post('/edit/{id}/{username}', [UsersController::class, 'editPost'])->name('users.edit-index');
});
Route::middleware('role:perks,xp_edit')->prefix('xp')->group(function () {
Route::post('/edit/{uid}', [XpController::class, 'editXp'])->name('xp.edit-xp');
});
when i try to access
users/edit/8
the middleware works fine, but for the xp routes i get this error
Unresolvable dependency resolving [Parameter #0 [ <required> $request ]] in class Illuminate\Http\Client\Request
The error message talks about Illuminate\Http\Client\Request. Usually you'd be dealing with Illuminate\Http\Request. The $next call is probably trying to invoke a controller method that has type-hinted the wrong class in its arguments.
Check if you're importing the wrong Request class in your controller.
Please or to participate in this conversation.