Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cupcaved's avatar

Laravel web auth not working

Hello

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.

0 likes
2 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@cupcaved

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

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

'defaults' => [
    'guard' => 'admins',
    'passwords' => 'users',
],
1 like
angelinmay's avatar

Your default guard is web, but there is no web guard in guards. You can create new guards: admin and student, but please keep the web guard in guards as well.

Please or to participate in this conversation.