Multiple Auth Role – Laravel

Kali ini kita akan membuat Login yang terpisah untuk Admin dan User. Kita akan menempatkan model pada folder Models. untuk itu update file config/auth.php dibagian provider ubah menjadi:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Models\User::class,
    ],
],

Admin Model, Migration and Seed

In our application we want to have a separate login for our admin section and separate login for the customers, keeping this in mind we will add a new model called Admin. As I said earlier, Laravel comes with a User model which we will use for our customers, for the purpose of their login, registration and accounts management.

Now we will start creating the model, migrations, and seed for the Admin. Go to your terminal and run below artisan commands to generate the model, migrations and database seed.

php artisan make:model Models\\Admin -m
php artisan make:seed AdminsTableSeeder