【发布时间】:2016-05-11 00:26:03
【问题描述】:
我是 Laravel 新手,我正在尝试根据存储在数据库中的 ID 在不同页面上重定向 2 种不同类型的用户。
我在redirectifAuthenticated.php 文件中找到了验证重定向代码。我不知道我在代码中做错了什么才能成功重定向。下面是我的代码。
public function handle($request, Closure $next){
if ($this->auth->check()){
$userId = Auth::id();
if($userId == '1'){
return new RedirectResponse(url('/symptoms/view'));
}else{
return new RedirectResponse(url('/home'));
}
}
return $next($request);
}
【问题讨论】:
-
在您的帖子中添加中间件代码
-
哪个中间件代码? authenticate.php 还是 verifycsrftoken?
-
只需执行“return redirect(url('/symptoms/view'));”无需使用 RedirectResponse 类...
-
查看我对此的回答:stackoverflow.com/q/34880747/2668477
标签: php authentication redirect laravel-5