app->singleton(TenantManager::class, function () { $tenant = null; if (!app()->runningInConsole()) { $tenant = Tenant::where('domain', explode(".", request()->getHost())[0]) ->with(['users', 'settings']) ->first(); if (is_null($tenant)) { abort(404, 'Tenant ' . explode(".", request()->getHost())[0] . ' not found (' . request()->getHost() . ')'); die(); } } return new TenantManager($tenant); }); } }