php - how to i search on search results in laravel 4.2 -


there simple page display search results keywords. want search on results criteria.

how can

searchcontroller

class searchcontroller extends \basecontroller {      public function search() {         $keyword = input::get('header-search-query');          if (empty($keyword)) {             $product = product::paginate(10);             $this - > setmodel($product);             return view::make('product.listbykeyword') - > with('products', $product);         }          return view::make('product.listbykeyword') - > with('products', product::like('title', $keyword) - > paginate(10));     }      public function advance() {         //what should put here     } } 

view

@foreach($products $product)  <div class="media">     <div class="media-left" style="width:16%;">         <a href="{{ url::to('image/'.$product->productimage()->first()['image']) }}">         {{ html::image('image/'.$product->productimage()->first()['image'],'no-image',array('class'=>'media-object','height'=>'100','width'=>'100'))}}          </a>      </div>  <div class="media-body">      <h4 class="media-heading">{{ html::link('/product/'.$product->id,$product->title) }}</h4>      <p>{{substr($product->description,0,85)}}</p>      <p>price : {{$product->price}} tk</p>      <p class="time">{{$product->created_at->diffforhumans()}}           <b>near</b> {{$product->location}}      </p>   </div>  </div>  <hr></hr> @endforeach 

as true can't able use datatables in case public search recommend use ajax call on keychange event.

step 1 :

detect keychange textbox

<input id='mytextbox1' type='text'/> $('#mytextbox1').on('input', function() {     alert('text1 changed!'); }); 

here fiddle

step 2 :

call ajax page controller

 $.ajax({         type: "post",         url : "yourcontroller",         data : datastring,         success : function(data){         $("#result").html(data);                                    }   }); 

place div named result in page.

so, first time result default controller use search , next time whenever type text in mytextbox1 call controller yourcontroller , in controller should datastring , return matching output view.

hope helps you.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -