我正在对登录进行条件验证,因此用户将分别重定向到其页面。我的代码是:
protected $redirectTo = '/';
protected function redirectTo()
{
if (auth()->user()->department == 'HR' || 'Human Resource' ) {
return '/hr';
}
elseif (auth()->user()->department == 'Accountant' || 'ACC' ) {
return '/acc';
}
else return '/';
}
但是,当我运行代码时,页面被重定向到错误的页面。如何在参数中添加OR子句?
答案 0 :(得分:1)
protected function redirectTo()
{
if ((auth()->user()->department == 'HR') || (auth()->user()->department == 'Human Resource')) {
return '/hr';
}
elseif ((auth()->user()->department == 'Accountant') || (auth()->user()->department == 'ACC')) {
return '/acc';
}
else return '/';
}
答案 1 :(得分:1)
尝试不直接使用此方法||
((auth()->user()->department == 'HR') || (auth()->user()->department == 'Human Resource'))
((auth()->user()->department == 'Accountant') || (auth()->user()->department == 'ACC'))