Following the Laravel 4 documentation on Routing, I've been trying to create a domain route that will handle a wildcard subdomain and pass it over to a controller action, but I'm having trouble passing the argument.
Route::group(array('domain' => '{subdomain}.myapp.com'), function()
{
Route::get('/', function($subdomain)
{
die($subdomain);
});
});
If I write the route like this, it will print out the subdomain, whatever it might be. The problem is that I don't want to write the code that handles these situations in the routes.php file, but use a Controller to handle it all, without redirecting from subdomain.myapp.com to myapp.com/controller/action/subdomain. So, something like this:
Route::group(array('domain' => '{subdomain}.myapp.com'), function()
{
Route::get('/', 'MyController@myAction', $subdomain);
});
How do I pass the {subdomain} argument to the controller in this case?