1

I'm getting the error:

Auth guard [accountant] is not defined.

This is my config\auth.php file

<?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,
 ],
],
];

The previous guard admin is working fine. But the accountant guard is throwing an error. What have I done incorrectly?

I have added the guard in the model as well

Paul-Beyond
1,7671 gold badge14 silver badges31 bronze badges
asked Jul 1, 2017 at 6:57
3
  • 1
    Maybe try a php artisan config:clear? Commented Jul 1, 2017 at 7:05
  • 1
    That worked. Why does this happen? Does laravel cache the config file? Commented Jul 1, 2017 at 7:11
  • Not 100% sure but I've been bitten by it in the past too, I'll add an answer Commented Jul 1, 2017 at 7:11

1 Answer 1

2

You may need to clear the config cache:

php artisan config:clear

Here are the docs on configuration caching: https://laravel.com/docs/5.4/configuration#configuration-caching

You may have previously run the config:cache command on your dev instance

answered Jul 1, 2017 at 7:12
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.