DEV Community

AjayMalhotra
AjayMalhotra

Posted on

1

Laravel - redirect user based on usertype

https://therichpost.com/laravel-7-how-to-redirect-authenticated-users-based-on-user-type/

Thank you

Top comments (1)

Collapse
 
auniik profile image
Auniik Datta
protected function authenticated(Request $request)
{
      return redirect(
          [
              'admin'  => '/admin/dashboard/',
              'superadmin' => '/superadmin/dashboard/'
          ][ auth()->user()->userType ]
    );
}

How's that ?

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs