I have not done much work with route service providers and there seems to have been some changes around Laravel 5.4.
Basically I wish to use the boot function in route service provider to retrieve the sub domain so I can then query the main database to then set the sub database config and reconnection. I understand this could be done through middleware, however wish to do it through service providers.
Route
Route::group(['domain' => '{account}.prop.dev'], function() {
Route::get('/login', function () {
return 'login';
});
});
I cant see any problems with the above and where I dump in the route service provider it dumps but if I make a function the function doesnt seem to run and I have not managed to retrieve the subdomain.
There seems to be a lot of information using
$router->
but have struggled to find information using
Route::
My route service provider attempt is as follows:
public function boot()
{
parent::boot();
Route::pattern('domain', '[a-z0-9.]+');
Route::bind('domain', function ($value) {
$domain= Customer::whereSubdomain($value)->first();
if ($domain) {
return $domain;
}
throw new Exception('error message');
});
}
Any help would be great.