I have a form like the following
<form id="formD" class="ui form error" action="{{route('search')}}" method="post">
<div class="field">
<div class="ui fluid icon input">
<input id="wname" name="wname" type="text" placeholder="Nombre Wi-Fi...">
<i id="search" class="inverted circular search link icon"></i>
</div>
</div>
<div class="field">
<div class="ui checkbox">
<input id="terms" type="checkbox" name="terms">
<label>Acepto los terminos y condiciones.</label>
</div>
</div>
{!! csrf_field() !!}
<div class="ui error message" id="eSer"></div>
</form>
That only passes the parameters by post to the controller, it receives the data and processes it and returns in this case as follows
return view('index',['wifis'=>$wifi]);
And everything works fine, but what happens if the user presses f5 on the view that I just returned, a message will appear saying that if you want to resubmit the form and I want to avoid that, what could be done, I know that doing a redirect would solve it, but I need that in the view the data that I am passing to the view is shown, which in this case is the wifis variable.
Clarification
my routes are the following
Route::get('/',[
'uses'=>'Admin@indexView',
'as'=>'index'
]);
Route::post('/',[
'uses'=>'Admin@indexSearch',
'as'=>'search'
]);
My two controller methods are
public function indexView(){
return view('index');
}
public function indexSearch(Request $request){
//procesos
return view('index',['wifis'=>$wifi]);
}
Perhaps the most typical and simple way is to use the session to store the data and get it when the redirection is done.
I assume there is a view that displays the form:
In the controller method that receives the form:
So you simply have two routes that lead to the same method and controller:
The only thing that remains to be done is how you determine when to clear the Wi-Fi value stored in the session, but it depends on your implementation and your design.