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();
}
return redirect()->route('home');
Laravel routes are located in the app/Http/routes. php file. A route usually has the URL path, and a handler function callback, which is usually a function written in a certain controller.
Redirect to a specific page in Laravel using ajax - Stack In order to redirect everything on web routes, you can add the following piece of code in your app's route/web. php file Route::any( '{catchall}', function(){ // return redirect( 'https://digitizor.com' ) // OR, Do something here })->where( 'catchall', '.
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*/ ]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With