title: Get the subdomain in a subdomain-route (Laravel)
body: <p>I'm building an application where a subdomain points to a user. How can I get the subdomain-part of the address elsewhere than in a route?</p>
  
  <pre><code>Route::group(array('domain' =&gt; '{subdomain}.project.dev'), function() {
  
      Route::get('foo', function($subdomain) {
          // Here I can access $subdomain
      });
  
      // How can I get $subdomain here?
  
  });
  </code></pre>
  
  <p>I've built a messy work-around, though:</p>
  
  <pre><code>Route::bind('subdomain', function($subdomain) {
  
      // Use IoC to store the variable for use anywhere
      App::bindIf('subdomain', function($app) use($subdomain) {
          return $subdomain;
      });
  
      // We are technically replacing the subdomain-variable
      // However, we don't need to change it
      return $subdomain;
  
  });
  </code></pre>
  
  <p>The reason I want to use the variable outside a route is to establish a database-connection based on that variable.</p>