1
votes

I am using backpack for laravel V4, Laravel 6, I defined roles and permissions and assigned file-manager permission and manager role to a user. When I try to use it in route middleware I get Forbidden Error 403, what I tried: in routes/backpack/custom.php

'middleware' => ['web', config('backpack.base.middleware_key', 'admin'), 'can:file-manager']

when I use as instructed in spatie/laravel-permission documentation :

Route::group(['middleware' => ['role:manager']], function () {
    //
});

I receive Target class [role] does not exist error.

I searched different places but no luck, please advise the right way to use permission manager in routes.

1

1 Answers

2
votes

I ran into the same issue.

You must add the RoleMiddleware to your config, in app/Http/Kernel.php :

protected $routeMiddleware = [
   'auth' => \App\Http\Middleware\Authenticate::class,
   // [...]
   'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
];

My answer is a bit late, but I hope it will help others :)