Oct 24, 2024
8
Level 6
different login via role direct to specific dashboard
I need to limit access to a role I created and redirect after login to a specific page, I use spatie for permissions and roles, reading online I found that I had to insert this code to redirect to a specific page but it doesn't work, and I inserted this in the sidebar and it doesn't work either,
LoginController
protected function authenticated(Request $request, $user)
{
if ($user->hasRole('customer')) {
return redirect()->route('customer-dashboard');
} elseif ($user->hasRole('admin')) {
return redirect()->route('dashboard');
} elseif ($user->hasRole('operator')) {
return redirect()->route('dashboard');
} elseif ($user->hasRole('office')) {
return redirect()->route('dashboard');
} elseif ($user->hasRole('manager')) {
return redirect()->route('dashboard');
} else {
return redirect('/dashboard');
}
}
sidebar.blade.php
@can('permission')
@can('customer')
@andcan
@andcan
Please or to participate in this conversation.