Support the ongoing development of Laravel.io →
Input Forms Architecture

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)

Last updated 3 years ago.
0

on success form submission you can redirect the user?

at the end of you controller try,

return redirect('/some/path');
0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

exelrate exelrate Joined 13 Oct 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.