jeudi 3 décembre 2015

Laravel 5 (URL not showing search parameters)

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']) !!}

      <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)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire