Tanvir Ahmed
Tanvir Ahmed

Reputation: 1019

How to solve Auth guard [web] is not defined problem

I make 2 guards 1. For admin and 2. for student. Now when i click on my button to show the login form i always caught that error that Auth guard [web] is not defined.Now how i solve this. here is my config/auth.php

 'defaults' => [
        'guard' => 'web',
        'passwords' => 'users',
    ],
 'guards' => [
        'admin' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
        'student' => [
            'driver' => 'session',
            'provider' => 'student',
        ],

        'api' => [
            'driver' => 'token',
            'provider' => 'users',
            'hash' => false,
        ],
    ],
    'providers' => [
        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],
        'students' => [
            'driver' => 'eloquent',
            'model' => App\Student::class,
        ],

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

I am trying login the admin using admin guard.Please help me to solve that and i dont use default User.php model.

Full error message

Upvotes: 5

Views: 10745

Answers (1)

nmfzone
nmfzone

Reputation: 2903

That's because you're removing web guard from the application.

Just change your default guard from web to your new guard.

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

Upvotes: 11

Related Questions