normalize($request->getHost()); $business = BusinessDomain::query() ->where('hostname', $hostname) ->where('isActive', true) ->with('business') ->first()?->business; } 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)->forget(); } if ($business) { app(TenantContext::class)->set($business); } return $next($request); } }