title: How to build a Laravel route that requires a specific URL query parameter?
body: <p>Let's say I have URLs like this:</p>
  
  <ol>
  <li>localhost/<strong>admin/users/</strong> <em>&lt;--- Main Admin Users page</em></li>
  <li>localhost/<strong>admin/users/?data=refresh</strong> <em>&lt;---- A typical ajax request made from that page</em></li>
  </ol>
  
  <p>And a simple controller like this:</p>
  
  <pre><code>class UsersController extends Controller {
  
       public function index()
  
           // call some services
           // return a view
       }
  
       public function dataRefresh {
  
           // call some services
           // return some JSON
       }
  }
  </code></pre>
  
  <p>And here's my routes.php I'm working on:</p>
  
  <pre><code>    Route::get('admin/users', array('as' =&gt; 'admin.users', 'uses' =&gt; 'Admin\Users\UsersController@index'));
      Route::get('admin/users????' , array('before' =&gt; 'ajax', 'as' =&gt; 'admin.users', 'uses' =&gt; 'Admin\Users\UsersController@dataRefresh'));
  </code></pre>
  
  <p><strong>What can I do in my second route to require a URL query parameter</strong> <code>?data</code> <strong>and furthermore require it is set to</strong> <code>data=refresh</code><strong>?</strong> And how do I ensure it doesn't conflict with the other route?</p>
  
  <p>Note:
  I'm aware this may not be considered "pretty URL" by some.  I do implement pretty URLs / slugs when appropriate, however I also think there are many cases where the query parameters are more clearer and cleaner (ie. give a user a clear understanding of what part of the page's URL is for filtering the data in a datagrid...and assures a user the parameters can be removed without causing the page to break or go missing). Google does this themselves, as well as many other reputable sites.</p>
  
  <p>Note: I have applied an ajax route filter to the second route. I've also set the route to point towards the dataRefresh method in my controller. </p>
  
  <p>This is as far as I've got. Any ideas?</p>