mercredi 1 juin 2016

How to pass parameters to a redirect route in Request

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();
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire