i wanna to redirect each user to his page deppends on his role and this is the redirectTo() that i have made in loginController , each login they redirect me to home page and they don't access to redirectTo methode
public function redirectTo()
{
$role = Auth::user()->roles;
$role="codingTeam";
switch($role){
case 'codingTeam':
return '/codingTeam';
break;
case 'admin':
return '/admin';
break;
case 'secretariat':
return '/secretariat';
break;
default:
return 'auth/login';
break;
}
}
In LoginController u have protected $redirectTo
property. If u want to make redirect()
first u need to define your redirectTo
property,
private function redirectTo()
{
$role = Auth::user()->roles;
$role="codingTeam";
switch($role){
case 'codingTeam':
$this->redirectTo = '/codingTeam';
break;
case 'admin':
$this->redirectTo = '/admin';
break;
case 'secretariat':
$this->redirectTo = '/secretariat';
break;
default:
$this->redirectTo = 'auth/login';
break;
}
}
and after in action use call $this->redirectTo()
and after return redirect($this->redirectPath())
try this
private function redirectTo()
{
$role = Auth::user()->roles;
$role="codingTeam";
switch($role){
case 'codingTeam':
return redirect('/codingTeam') ;
break;
case 'admin':
return redirect('/admin');
break;
case 'secretariat':
return redirect('/secretariat');
break;
default:
return redirect('auth/login');
break;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.