PHP Laravel自定义保护错误

时间:2017-07-01 06:57:42

标签: php laravel

我收到错误:

  

未定义Auth guard [accountant]。

这是我的config\auth.php文件

<?php



 return [

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



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

    'api' => [
        'driver' => 'token',
        'provider' => 'users',
    ],
    'admin' => [
        'driver' => 'session',
        'provider' => 'admins',
    ],
     'admin-api' => [
        'driver' => 'token',
        'provider' => 'admins',
    ],
    'accountant' => [
        'driver' => 'session',
        'provider' => 'accountants',
    ],
],


'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\User::class,
    ],
     'admins' => [
        'driver' => 'eloquent',
        'model' => App\Admin::class,
    ],
    'accountants' => [
        'driver' => 'eloquent',
        'model' => App\Accountant::class,
    ],

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


'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => 'password_resets',
        'expire' => 60,
    ],
      'admins' => [
        'provider' => 'admins',
        'table' => 'password_resets',
        'expire' => 60,
    ],
    'accountants' => [
        'provider' => 'accountants',
        'table' => 'password_resets',
        'expire' => 60,
    ],
],

];

以前的后卫管理员工作正常。但会计师后卫正在抛出错误。我做错了什么?

我已经在模型中添加了守卫

1 个答案:

答案 0 :(得分:2)

您可能需要清除配置缓存:

php artisan config:clear

以下是有关配置缓存的文档:https://laravel.com/docs/5.4/configuration#configuration-caching

您之前可能已在开发实例上运行config:cache命令