Jul*_*oro 3 routes laravel laravel-5
我需要使用以下 URL 注册参加锦标赛:
http://laravel.dev/tournaments/1/register/
Run Code Online (Sandbox Code Playgroud)
该 URL 位于中间件“auth”中,因此如果用户未登录,他将被重定向到登录/页面。
我需要的是重定向到
http://laravel.dev/tournaments/1/register/
Run Code Online (Sandbox Code Playgroud)
登录后。
在我的routes.php中,我有:
Route::get('tournaments/{tournamentId}/register', 'TournamentController@register');
Run Code Online (Sandbox Code Playgroud)
我被告知要使用
redirect()->intended
Run Code Online (Sandbox Code Playgroud)
但我不知道该怎么做。
在一般情况下,用户将被重定向到/admin,但在这种情况下,我希望他继续执行他的主要操作(注册锦标赛)...
我使用内置特征进行登录,因此我检查了系统在登录时执行的操作,并且它已经在使用此功能:
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::guard($this->getGuard())->user());
}
return redirect()->intended($this->redirectPath());
}
Run Code Online (Sandbox Code Playgroud)
问题是它会将我重定向到默认路径,而不是动态路径......
小智 5
您应该了解“重定向至”和“重定向预期”之间的区别
Redirect Intended: redirects the user to where they were originally going
Redirect To: Redirect the user to the page **YOU** specify them to go.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25529 次 |
| 最近记录: |