laravel/framework — pull request #4633 by lucasmichot (2014-06-09 13:40:28+00:00)
Title: [4.2] Router : add subdomain

Simple yet useful (IMO) : add `subdomain` feature to `Router`.
Of course, if no `domain` is set, `subdomain` becomes useless and is not taken into consideration.

The following:
````php
Route::group(['subdomain' => 'test'], function () {
// http://*/test
Route::get('test', function () {
return 'no domain';
});
});

Route::group(['domain' => 'bar.baz'], function () {
// http://bar.baz/
Route::get(null, function () {
return 'no subdomain';
});

// http://api.bar.baz/
Route::get(null, ['subdomain' => 'api', 'uses' => function () {
return 'api subdomain for bar.baz';
}]);
});

Route::group(['domain' => 'foo.com', 'subdomain' => 'www'], function () {
// http://api.foo.com/
Route::get(null, ['subdomain' => 'api', 'uses' => function () {
return 'api subdomain forced';
}]);

// http://baz.test/
Route::get('override', ['domain' => 'baz.test', function () {
return 'group domain overridden : www subdomain is not taken';
}]);

// http://www.foo.com/
Route::get(null, function () {
return 'get group domain and subdomain';
});
});
````
will provide these routes:
```sh
+-------------+-------------------+------+---------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+-------------+-------------------+------+---------+----------------+---------------+
| | GET|HEAD test | | Closure | | |
| bar.baz | GET|HEAD / | | Closure | | |
| api.bar.baz | GET|HEAD / | | Closure | | |
| api.foo.com | GET|HEAD / | | Closure | | |
| baz.test | GET|HEAD override | | Closure | | |
| www.foo.com | GET|HEAD / | | Closure | | |
+-------------+-------------------+------+---------+----------------+---------------+
```