getHost(), '.')); try { $business = BusinessDomain::query() ->where('hostname', $hostname) ->where('isActive', true) ->with('business') ->first()?->business; if (! $business && app()->environment('local')) { $slug = config('app.default_business_slug'); $business = $slug ? Business::query()->where('slug', $slug)->first() : null; } } catch (Throwable) { // The install page and framework smoke tests must remain // reachable before the tenant schema has been created. $business = null; } if ($business) { app(TenantContext::class)->set($business); } return $next($request); } }