2

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.

apokryfos
  • 38,771
  • 9
  • 70
  • 114
  • 1
    usually each auth model would have one guard, so you need to complete the multi guard setup first b4 using spatie, 2nd you need to create roles & perms according to each guard, 3rd change the roles check middleware to work with multi guards per route check otherwise it wont work. – ctf0 Nov 20 '20 at 06:09

0 Answers0