我想知道是否有可能使我的每个控制器的身份验证重定向不同?目前,一切都重定向到/ home。这是为我的HomeController设计的。但对于ClientController,我希望它重定向到/客户端(如果通过身份验证)而不是/ home。我是否必须为每个控制器创建一个新的中间件,或者是否有办法通过重用auth来完成此操作?Laravel 5.2如何根据控制器更改RedirectIfAuthenticated的重定向?
RedirectIfAuthenticated.php
if (Auth::guard($guard)->check()) {
return redirect('/home'); //anyway to change this to /client if coming from ClientController?
}
我有这对我的ClientController.php
public function __construct()
{
$this->middleware('auth');
}
提前感谢!对Laravel和中间件来说相当新颖。
尝试过,但它不会改变一件事,加$ redirectTo ='/ client';在我的用户模型上。一切工作正常,只要放置Route :: resource('client','ClientController');在Route :: group(['middleware'=> ['web']],在routes.php中的function(){ } –