title: Laravel sub-domain routing without passing variable to URL::route()
body: <p>In a Laravel 4 app, i'm using subdomain routing around a bunch of Route::resource's like this:</p>
  
  <pre><code>Route::group(['domain' =&gt; '{account}.my.app'], function()
  {
      Route::group(['before' =&gt; 'auth'], function($account)
      {
          Route::resource('organisations', 'OrganisationsController');
          Route::resource('clients', 'ClientsController');
          Route::resource('domains', 'DomainsController');
      });
  });
  </code></pre>
  
  <p>In my auth filter i'm doing the following:</p>
  
  <pre><code>Route::filter('auth', function($route)
  {
      // you could now access $account in a controller if it was passed as an argument to the method
      $account = $route-&gt;getParameter('account');
  
      // share account variable with all views
      View::share('account', $account);
  
      // Auth::guest Returns true if the current user is not logged in (a guest).
      if (Auth::guest()) return Redirect::guest('login');
  });
  </code></pre>
  
  <p>Within my views I can now access <code>$account</code>, but if I want a call to <code>URL::route()</code> to be correct I have to manually pass the account variable, like <code>URL::route('clients.show',['account' =&gt; $account])</code> otherwise it generates URLs like <code>%7Baccount%7D.my.app</code>.</p>
  
  <p>This is a bit of a pain and doesn't seem that elegant, is there any other or better way to achieve this? I guess I could create my own route helper to use instead of the built-in one.
  However, I also do redirects with Redirect::route() within controllers so I would also need to make updates here.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As suggested in the comments it may be that extending the Route API is the best approach here. Does anyone have any suggestions how this should be done?</p>
  
  <p>Thanks.</p>