我正在使用Laravel 5.6。*。现在,我为子域和主域创建了明智的路由。还为子域创建中间件。但是,当我浏览我的网站时,出现“缺少[Route:something] [URI:something]所需的参数”错误
我的路线文件
$domain = '{s_domain}.' . parse_url(config('app.url'), PHP_URL_HOST);
Route::group(['domain' => $domain, 'middleware' => 'subdomain'], function () {
Auth::routes();
Route::group(['namespace' => 'Clients', 'middleware' => 'auth'], function () {
Route::get('dashboard', 'ClientDashboardController@index')->name('home');
});
});
$maindomain = parse_url(config('app.url'), PHP_URL_HOST);
Route::group(['domain' => $maindomain], function () {
// My Route
});
我的子域Middlware文件
public function handle($request, Closure $next)
{
$subdomain = $request->route()->s_domain;
$customer = Customer::where( 'sub_domain', $subdomain )->where('status', 'On')->first();
if( ! $customer ) {
return redirect()->route('customer.inactive');
} else {
Config::set('database.connections.subdomain.database', $customer->customer_database);
Config::set('database.default', 'subdomain');
\DB::purge('subdomain');
\DB::reconnect('subdomain');
}
return $next($request);
}