I want to redirect a user to user-dashboard after login while redirect an admin to admin-dashboard after login in Laravel 9. How can i achieve this?
If you are using use Illuminate\Foundation\Auth\AuthenticatesUsers;
in your loginController
you can do:
Assuming you are using Roles Package, you can do the check with HasRole or whatever field/method your project has..
public function authenticated()
{
if(auth()->user()->hasRole('admin'))
{
return redirect('/admin-dashboard');
}
return redirect('/user-dashboard');
}