Reputation: 429
Language is a model binding in route file.
Route
Route::post('managment/{Language}/create', ['as' => 'dictionary.store', 'uses' => 'DictionaryController@store' ]);
I like to declare a Request (DictionaryRequest) file which extends Request(FormRequest), and it's responsible for the request parameter at Controller.
method prototype is :
public function store(DictionaryRequest $request, Language $lang)
the redirectRoute in the request class is set as :
protected $redirectRoute = "dictionary.create";
how can I pass on parameter to the route?? (the Langauge model)
I checked FormRequest class, but redirectRoute just passes on to the UrlGenerator with no parameters.
/**
* 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();
}
Upvotes: 5
Views: 3061
Reputation: 4795
Did you try override 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*/ ]);
}
Upvotes: 6