title: How to use optional route parameters properly with Laravel 5.6?
body: <p>I am trying to create an API with Laravel 5.6, however, it seems to me that it's not possible to use optional route parameters before/after the parameter.</p>
  
  <p>I'd like to achieve the following:</p>
  
  <pre><code>Route::get('api/lists/{id?}/items', 
  [
      'as'    =&gt; 'api/lists/items/get', 
      'uses'  =&gt; 'ListsController@getListItems'
  ]);
  </code></pre>
  
  <p>With the above scenario, if I'm trying to visit <code>api/lists/1/items</code> it shows the page. On the other hand, if I'm trying to visit <code>api/lists/items</code> it says that the page is not found.</p>
  
  <p>What I basically want is if there's no List ID specified, Laravel should fetch all the List ID's items, otherwise it should only fetch the specific ID's items.</p>
  
  <p><strong>Q:</strong> How is it possible to the optional parameter in between the 'route words'? Is it even possible? Or is there an alternative solution to this?</p>