What is best for Laravel Login?

Asked by At

I am creating an app, where they got different landing page when logged in, what is the best here multiple auth guard or login by usertype?

like multiple auth guard got different table for (admin, employee, user) while the usertype is there is column(usertype) in User table.

Multi Auth Example: https://medium.com/hello-laravel/multiple-authentication-system-laravel-5-4-ac94c759638a

Usertype Example: https://medium.com/justlaravel/how-to-use-middleware-for-content-restriction-based-on-user-role-in-laravel-2d0d8f8e94c6

1 Answers

Osama Alvi On

You can use RedirectIfAuthenticated middleware and handle request something like this:

$guard = Auth::guard($guard);

        if ($guard->check()) {
            $user = $guard->user();

            if ($user->userType === 'admin') {
                return redirect('/adminPage');


        return $next($request);