In this tutorial we are going to show you how to implement multi authentication system in your laravel app with specific guards.
In this example we will add admin auth.
First you need install this package through Composer.
1 2 3 | composer require hesto/multi-auth |
then if your laravel version is lower than 5.5 you have to add the provider in app/Providers/AppServiceProvider.php
like this :
1 2 3 4 5 6 7 8 | public function register() { if ($this->app->environment() == 'local') { $this->app->register('Hesto\MultiAuth\MultiAuthServiceProvider'); } } |
Now let’s add admin auth with artisan command and the package will set up everything for us.
1 2 3 | php artisan multi-auth:install admin -f |
Notice: If you don’t provide -f
flag, it will not work. It is a protection against accidental activation.
next we have to migrate the Migration of admin model
1 2 3 | php artisan migrate |
To try your new authentication just go to: http://project_url/admin/login
For more information about the package check the github link
I hope you like it 😊
Leave a Reply