Laravel 5.4 登录后重定向到自定义网址
我正在使用Laravel框架5.4.10,并且我正在使用常规身份验证
php artisan make:auth
提供。我想保护整个应用程序,并在登录后将用户重定向到/themes。
我有4个控制器:ForgotPasswordController.php,LoginController.php,RegisterController.php和ResetPasswordController.php。我已将此行编辑为最后三行:
protected $redirectTo = '/themes';
这是我的路线/网络中的第一行.php:
Auth::routes();
我已经在我的控制器中添加了这个函数.php:
public function __construct()
{
$this->middleware('auth');
}
我已经编辑了app / Http / Middleware / RedirectIfAuthenticated.php,因此句柄函数如下所示:
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/themes');
}
return $next($request);
}
一切都很好,除了当我点击登录按钮时,我被重定向到“/”,而不是“/themes”。如果我不需要在控制器中进行身份验证(控制器.php文件中没有__contruct功能),则在登录时我会被重定向为OK。我做错了什么?