title: Multiple where conditions in Laravel 5.1
body: <p>i have a problem in my multiple filters implementation. I have some checkboxes that pass to AJAX some params that can have multiple values.
  In my controller i have written this to handle this params:</p>
  
  <pre><code>function getCategoria(Request $request) {
      $path_info = Request::getPathInfo();
      $path = substr($path_info, 1);
      $links = explode('/', $path);
      $categorie = \App\Models\Categorie::where('primaria',1)-&gt;get();
      $categoria = \App\Models\Categorie::where('link_statico', $path)-&gt;first(); 
      $categoriaz = \App\Models\Categorie::where('link_statico', $path)-&gt;first(); 
      $id = ucfirst($links[0]);
  
      $prodottip = \App\Models\Prdotticategorie::where('prodotti2categorie.id_categoria', $categoriaz-&gt;id)-&gt;join('prodotti', 'prodotti.id', '=', 'prodotti2categorie.id_prodotto')-&gt;query();
  
      $brands = Input::get('brands');
      $genere = Input::get('genere');
      $stagione = Input::get('stagione');
      $this-&gt;data['links'] =  $links;
      $this-&gt;data['categorie'] =  $categorie;
      $this-&gt;data['categoria'] = $categoria;  
      $this-&gt;data['categoriaz'] = $categoriaz;
      $this-&gt;data['id'] = $id;
      $this-&gt;data['pages'] = 'categorie.frontend';
      if(count($brands) &gt; 0 &amp;&amp; count($genere) &gt; 0 &amp;&amp; count($stagione) &gt; 0) 
      {
          if(count($brands) &gt; 0)
          {
              $brands_array = [];
                  if(is_array($brands) || is_object($brands)) 
                  {
                      foreach ($brands as $brand) 
                      {
                          $brands_array[] = $brand;
                      }
                          $rst = $prodottip-&gt;whereIn('prodotti.id_produttore', $brands_array);
                  }
          } 
          if(count($genere) &gt; 0)  
          {
              $genere_array = [];
                  if(is_array($genere) || is_object($genere)) 
                  {
                      foreach ($genere as $gen) 
                      {
                          $genere_array[] = $gen;
                      }
                          $rst = $prodottip-&gt;whereIn('prodotti.genere', $genere_array);
                  }
          } 
          if (count($stagione) &gt; 0) 
          {
              $stagione_array = [];
                  if(is_array($stagione) || is_object($stagione)) 
                  {
                      foreach ($stagione as $stag) 
                      {
                          $stagione_array[] = $gen;
                      }
                          $rst = $prodottip-&gt;whereIn('prodotti.stagione', $stagione_array);
                  }
          }
          $prodottix = $rst-&gt;paginate(18);
      } else {
          $prodottix = $prodottip-&gt;paginate(18);
  
      }
      $this-&gt;data['prodottix'] = $prodottix;
      if (Request::ajax()) {
          $page = 'layouts.'.CNF_THEME.'.categorie_ajax';
          $view = view($page, $this-&gt;data)-&gt;render();
          return response()-&gt;json(['html'=&gt;$view]);
  
      }
      $page = 'layouts.'.CNF_THEME.'.categorie';
      return view($page, $this-&gt;data);
  }
  </code></pre>
  
  <p>The problem is that AJAX reload correctly but the results remaining the same. I can bring it working only if i an elseif with different scenarios like this:</p>
  
  <pre><code>if(count($brands) &gt; 0 &amp;&amp; count($genere) &gt; 0 &amp;&amp; count($stagione) &gt; 0)
     //query with 3 where 
  elseif(count($brands) &gt; 0 &amp;&amp; count($genere) == 0 &amp;&amp; count($stagione) == 0)
    // query with 1 where
  </code></pre>
  
  <p>Hi have read something on DynamicScopes in Laravel, but i need more help thks</p>