I used the authentication system built in Laravel 6. I can't seem to redirect the users based on their roles.
These are my columns in users table:
- username
- password
- roleid
In my LoginController, I added this code:
public function redirectTo(){
// User role
$role = Auth::user()->roleid;
// Check user role
switch ($role) {
case 1:
return '/';
break;
case 2:
return '/application/candidates';
break;
}
}
When I tried to login using different credentials with different roles, I always end up on the root route.
Am I missing something?