title: How to filter search results in laravel
body: <p>I'm new to PHP and Laravel, and I'm working on a project where people will be able to enter information about certain products and services available in different locations. I've added search functionality to enable users to search the database for specific products, but I want to take if further. When users search for products and the results are displayed, I want them to be able to filter the results to see the products and services available in their specific location.</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Khaki extends Model {
      public function scopeSearch($query, $s) {
          return $query-&gt;where('what_size_do_you_want', 'like', '%' . $s . '%')-&gt;orWhere('camp_sites', 'like', '%' . $s . '%');
      }
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function index(Request  $request) {
      $s = $request-&gt;input('s');
      $khaki = Khaki::latest()-&gt;search($s)-&gt;paginate(10);
      return view('khaki.index', compact('khaki', 's'));
  }
  </code></pre>