Home » Php » php – Multiple guard assign rolling problem in laravel spatie permission

php – Multiple guard assign rolling problem in laravel spatie permission

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am using laravel spatie permission package.

I have three guard named…

  1. web
  2. api
  3. customer

Problem

There is no role named ‘customer’

I created a customer role with customer guard.

auth.php

    'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],


    'guards' => [

        'customer' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],

    ],

Here i changed guard order that that the official documentation followed.

Main question

The documentation says if i had multiple guard than add $guard_name property inside User model. but if i have more guards how to declare this specific guard.

How to&Answers: