我有一条我声明的路线;
Route::get('invite/{code}', ['middleware' => ['qwickLoggedIn'], 'uses' =>'WebController@signup_invite'])->name('signup_invite');
如您所见,路线有一个参数{code}
如何使用route
或url
?
就像下面的代码一样?
public function account_verification () {
$referer = Request::header('referer');
if ($referer != url('login') && $referer != url('signup') && $referer != url('invite/{code}') && $referer != url('account-verification-code')) {
return redirect()->route('/');
}
$year = $this->copyright_info('2015');
return view('pages.account-verification', ['year' => $year]);
}
我把它作为$referer != url('invite/{code}')
,但这不起作用。 $referer != url('invite')
也不起作用......也使用route('signup_invite');
我收到错误UrlGenerationException in UrlGenerationException.php line 17:
Missing required parameters for [Route: signup_invite] [URI: invite/{code}].
任何帮助表示赞赏
答案 0 :(得分:0)
看起来很混乱,但您可以使用$referrer
功能解析parse_url
功能&然后为组件设置条件:
$referer = Request::header('referer');
$path = parse_url($referer, PHP_URL_PATH);
$path = explode( '/', $path );
if ($referer != url('login') && $referer != url('signup') && ( parse_url($referer, PHP_URL_HOST) == parse_url( url('/'), PHP_URL_HOST ) && $path[1] == 'invite' && !empty($path[2]) ) && $referer != url('account-verification-code')) {
return redirect()->route('/');
}