Oct 25, 2018
0
Level 14
Custom redirect for Request validation
I need to redirect to custom route name if validation failed.
I see that I can use:
protected $redirectRoute = 'my.route.name';
However, I need to pass params to this url.
Seem that there is no way to do this as FormRequest use only route name, I found this method:
protected function getRedirectUrl()
{
$url = $this->redirector->getUrlGenerator();
if ($this->redirect) {
return $url->to($this->redirect);
} elseif ($this->redirectRoute) {
return $url->route($this->redirectRoute); // Route name is here without param
} elseif ($this->redirectAction) {
return $url->action($this->redirectAction);
}
return $url->previous();
}
Please or to participate in this conversation.