title: Apply multiple filters to a table in Laravel 5
body: <p>I have a vehicles table. In my vehicles search page, I filter the vehicles according to models, colors etc selected. </p>
  
  <p>In my code I tried to instantiate the vehicle model. Then applied the filters to it and tried to run query using get(), but feeds me with errors.</p>
  
  <p>Code here:</p>
  
  <pre><code>    $vehicles = Vehicle::all();
      if($request-&gt;input('model'))
      {
          $vehicles-&gt;whereHas('model', function($q)
          {
              $q-&gt;where('model_name', '=', 'CL');
  
          });
  
      }
      if($request-&gt;input('color'))
      {
          $vehicles-&gt;where('color', '=', 'red');
      }
      // other filters here
      $result = $vehicles-&gt;get();
      dd($result);
  </code></pre>
  
  <p>Here a single filter works if I directly use whereHas on the Vehicle model like Vehicle::whereHas(). What is the solution if I had to apply multiple filters based on conditions. 
  Who saves my day :)  </p>