语言是路径文件中的模型绑定。
路线
Route::post('managment/{Language}/create', ['as' => 'dictionary.store', 'uses' => 'DictionaryController@store' ]);
我想声明 Request (DictionaryRequest)文件,该文件扩展 Request(FormRequest),并且它负责Controller的请求参数。
方法原型是:
public function store(DictionaryRequest $request, Language $lang)
请求类中的redirectRoute设置为:
protected $redirectRoute = "dictionary.create";
如何将参数传递给路线? (Langauge模型)
我检查了FormRequest类,但是redirectRoute只是传递给没有参数的UrlGenerator。
/**
* Get the URL to redirect to on a validation error.
*
* @return string
*/
protected function getRedirectUrl()
{
$url = $this->redirector->getUrlGenerator();
if ($this->redirect) {
return $url->to($this->redirect);
} elseif ($this->redirectRoute) {
return $url->route($this->redirectRoute);
} elseif ($this->redirectAction) {
return $url->action($this->redirectAction);
}
return $url->previous();
}
答案 0 :(得分:3)
您是否尝试覆盖getRedirectUrl
?
/**
* Get the URL to redirect to on a validation error.
*
* @return string
*/
protected function getRedirectUrl()
{
$url = $this->redirector->getUrlGenerator();
return $url->route($this->redirectRoute, [ /*your parameters*/ ]);
}