title: Handling route with multiple optional parameters in Laravel
body: <p>I am trying to implement a filtering method for some products.</p>
  
  <p>This is the route:</p>
  
  <pre><code>Route::get('/TVs/{type?}/{producer?}', 'Product\AllProducts@getTVs')-&gt;where(['type' =&gt; '4kTV|curved|lcd|oled|plasma'], ['producer'=&gt;'Samsung'])-&gt;name('TVs');
  </code></pre>
  
  <p>And this is the controller function:</p>
  
  <pre><code>public function getTVs($type = null, $producer = null)
      {
          $products = DB::table('products')-&gt;paginate(16);
          if($type!=null) {
              $products = Product::where('type', $type)-&gt;paginate(16);
          }
          if($producer!=null) {
              $products = Product::where('description','like', '%'.$producer.'%')-&gt;paginate(16);
          }
          return view('product.TVs', ['products' =&gt; $products]);
      }
  </code></pre>
  
  <p>If I select the type, the page refreshes and shows the results. Then if i enter the producer, again it works. How can i make the route in such a way, that the order of the optional parameters does not matter and i can filter the results no matter the order ?</p>