I used to be for laravel 5.5 and earlier than https://github.com/Hesto/multi-auth .
But this repository don't update for laravel 5.6.
How to create multi auth in Laravel 5.6?
I used to be for laravel 5.5 and earlier than https://github.com/Hesto/multi-auth .
But this repository don't update for laravel 5.6.
How to create multi auth in Laravel 5.6?
After lots of digging and lots of questions & answers I have finally managed to work Laravel 5.6 Multi Auth with two table, So I'm writing Answer of my own Question.
How to implement Multi Auth in Larvel
As Mentioned above. Two table
admin
andusers
Laravel 5.2 has a new
artisan
command.php artisan make:auth
it will generate basic login/register
route
,view
andcontroller
foruser
table.Make a
admin
table asusers
table for simplicity.Controller For Admin
app/Http/Controllers/AdminAuth/AuthController
app/Http/Controllers/AdminAuth/PasswordController
(note: I just copied these files from
app/Http/Controllers/Auth/AuthController
here)config/auth.php
route.php
AdminAuth/AuthController.php
Add two methods and specify
$redirectTo
and$guard
it will help you to open another login form for admin
creating a middleware for
admin
}
register middleware in
kernel.php
use this middleware in
AdminController
e.g.,That's all needed to make it working and also to get json of authenticated admin use
Auth::guard('admin')->user()
We can access authenticated user directly using
Auth::user()
but if you have two authentication table then you have to usefor logout
for authenticated user json