Skip to content
Advertisement

How to redirect a user to different dashboards based on a level field in the ”’users”’ table in Laravel Breeze?

Please forgive me if my question is too generic but I am at my wits end.

I have a users table with a level field as shown given below:

$table->unsignedSmallInteger('level')->after('password');

I want to redirect the user to different dashboards based on the value of the level field. For example for level 0 user

admindashboard

for level 1 user

userdashboard

I am using Laravel 8.4 and laravel/breeze for authentication.

Thank You

Advertisement

Answer

Ok, found a solution.

  1. On routesweb.php I have commented out the default dashboard route and created a new route for /dashboard and pointed it to AppHttpControllersDashboardsController@index
JavaScript
  1. index function of DashboardsController
JavaScript

Basically this will accomplish what I want to achieve.

Thanks

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement