Currently my users must get the visit form given by Route::get
then fill it in to get back a result view given by Route::post
. I need to create a shareable link such as /account/search/vrm/{vrm}
where {vrm}
is the VRM that is usually filled in on the form page. This VRM then needs to redirected to Route::post
as post data. This needs to be done by my controller. How can I do this in my controller?
Routes:
// Shows form view
Route::get('/account/search', 'User\AccountController@getSearch')->name('account.search');
// Shows result view
Route::post('/account/search', 'User\AccountController@runSearch');
// Redirect to /account/search as POST
Route::get('/account/search/vrm/{vrm}', function($vrm) { ???????? });
POSTs cannot be redirected.
Your best bet is to have them land on a page that contains a form with <input type="hidden">
fields and some JavaScript that immediately re-submits it to the desired destination.
You can redirect to a controller action or call the controller directly, see the answer here:
In summary, setting the request method in the controller, or calling a controller's action.
Ps: I don't want to repeat the same thing.
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