New to Laravel,
My form looks like this
{!! Form::open(array('action' => array('SearchController@postReviews' ), 'class'=>'form-inline')) !!} <div class="form-group"> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <div class="input-group"> <div class="input-group-addon" style="width:110px;">Location</div> <input type="text" class="form-control " id="mapsearch" name="mapsearch" placeholder="Enter City,Pin or Address" style="height:43px; min-width:402px; font-size:1.0em;" required/> <div class="input-group-addon"> {!! Form::select('size', array('Car' => 'Car', '2-Wheeler' => '2-Wheeler'), 'Car', ['id'=> 'carmodel', 'class' => 'form-control
input-sm', 'style'=>'width:200px;', 'required']) !!} </div>
<input type="hidden" class="form-control input-sm" name="input_lat" id="input_lat" required> <input type="hidden" class="form-control input-sm" name="input_lng" id="input_lng" required> </div> <button type="submit" class="btn btn-danger" id="btn_search" style="width:200px;height:42px;">Search</button> </div> </form>
And my controller looks like
public function postReviews()
{
$location = Input::get('mapsearch');
$input_lat = Input::get('input_lat');
$input_lng = Input::get('input_lng');
$inputs = ($input_lat && $input_lng);
if (!$inputs) {
$input_lat = 22.5667;
$input_lng = 88.3667;
}......
Now everything is working fine. I am able to generate results with no issues. What is troubling me is when I hit search my URL remains the same. I.e. Before search URL is http://localhost/reviews After search URL is http://localhost/reviews what should I change so that my url after search button click shows
http://localhost/reviews/(value from mapsearch field)
on success form submission you can redirect the user?
at the end of you controller try,
return redirect('/some/path');
astroanu said:
on success form submission you can redirect the user?
at the end of you controller try,
return redirect('/some/path');
Thank you for the guidance. Do I need to create a route for this ? Or will this work without it. Also being a newbie, I would like to know how to achieve :
After hitting search in a form with input "Kolkata, India " the URL Changes from ..."exelrate.dev/reviews" to exelrate.dev/reviews/India/kolkata" and when I hit this URL again, the results are refreshed.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community