ok if i get you right you need to redirect diffrent users to their own dashboard.
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
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');
}
}
caffeinated, nicolaschi liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community