I want to make multiple authentication in my laravel project.
I create new guard "admin" in my auth.php file but I don't know how to set new created guard in my authcontroller.
It always use "defaults" settings from my auth.php:
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
1) If you wish to use newly created
admin
guard throughout the application, you can change the value in defaults of config file.2) If it is only about AuthController that uses Laravel's in built Auth system, you can add this line in the AuthController.php and PasswordController.php :
Ref - Check Guard Customization here
3) If you wish to you a guard other than default one for any Auth related task, you can specify it manually like this :
Ref - https://laravel.com/docs/5.2/authentication
Laravel 5.4+ uses the following in any Auth Controller:
You have to also register the guard in the
config\auth.php
admin is the guard name, provider is the TABLE-NAME