shouldBeSkipped(tenancy()->getRoute($request))) { return $next($request); } $domain = $this->getDomain($request); if ($this->isSubdomain($domain)) { $domain = $this->makeSubdomain($domain); if (is_object($domain) && $domain instanceof Exception) { $onFail = static::$onFail ?? function ($e) { throw $e; }; return $onFail($domain, $request, $next); } // If a Response instance was returned, we return it immediately. if (is_object($domain) && $domain instanceof Response) { return $domain; } } return $this->initializeTenancy( $request, $next, $domain ); } protected function isSubdomain(string $hostname): bool { return Str::endsWith($hostname, config('tenancy.central_domains')); } }