The given role or permission should use guard `` instead of `web`. -Laravel

You should check if in your model there is

protected $guard_name = 'web';

You need to specify the guard name in each model you use the role manager.

Since the roles are related to the guard you can't apply a role to a user with different guard

check the Documentation


class User extends Authenticatable
{
    // ...

    public function guardName(){
        return "web";
    }
}

I had the same error and I moved my User model to another folder, as I checked the auth.php file I noticed the pointer to User model is wrong so I changed it to the correct path and the problem solved.

Lravel default config file for auth.php

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

after I changed it to the correct path

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => Domain\User\Models\User::class, // just change it to the path, which your `User` model exists
    ],

    // 'users' => [
    //     'driver' => 'database',
    //     'table' => 'users',
    // ],
],

I had the same issue and it was because of typo in users model in config/auth.php. Also check your User class namespace.

Laravel model's guard is 'web' by default. You don't need to change it.

'users' => [
    'driver' => 'eloquent',
    'model' => App\Models\User::class,
],