Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Nova custom login

My Laravel project uses the following user types: students, parents, trainers. Now I would like to use Laravel Nova for the backend to manage the different resources.

Nova uses the users table, and model as default, however, I would like to use the admins table and model for the login.

I already created a custom admins table and model and updated the config/auth.php.

database/migrations/create_admins_table.php

...
public function up()
{
        Schema::create('admins', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name', 60);
            $table->string('email', 60)->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
}

config/auth.php

'guards' => [

        ...

        'admins' => [
            'driver' => 'session',
            'provider' => 'admins',
        ],
    ],

'providers' => [

        ...

        'admins' => [
            'driver' => 'eloquent',
            'model' => App\Admin::class,
        ],
    ],

What changes do I have to make to use the admins' table/guard for the Nova login?

like image 472
arety_ Avatar asked Oct 29 '25 15:10

arety_


1 Answers

In your /config folder, you'll find the file nova.php. Inside it, change the following line of code to specify your guard. For example:

'guard' => 'admins',

like image 150
udog Avatar answered Oct 31 '25 05:10

udog



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!