Support the ongoing development of Laravel.io →
Laravel Laravel.io Authorization
Last updated 6 months ago.
0

ok if i get you right you need to redirect diffrent users to their own dashboard.

0

or is it just the url slug you want to achieve?

0

if its to redirect users to diffrent dashboard:

step 1: create a controller

class HomeController extends Controller { public function index(){

    $role=Auth::User()->role;

    if($role=='admin'){

        return view('admin.dashboard');
    }

    if($role=='vendor'){

        return view('vendor.dashboard');
    }

    if($role=='vendor_agent'){

        return view('vendor_agent.dashboard');
    }

    else{
        return view('home');
    }
}

}

Step 2: Go to App folder then Http and the locate the Providers folder in it you will see a routeservice provider

change the value to redirects or anything you want public const HOME = 'redirect';

step 3:

Route::get('/redirect', [HomeController::class,'index']);

and PS dont forget to call the controller on the web.php

0

Go To your LoginController.php

 public function authenticated(Request $request, $user)  {

      if($user->hasrole('admin')){
          return redirect('/admin/dashboard');

      if($user->hasrole('user')){
          return redirect('/user/dashboard');
      }
  }
Last updated 1 year ago.
1

Sign in to participate in this thread!

Cloudways

Your banner here too?

Ruslan g-start2021 Joined 25 Aug 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.