*/ public static function hosts(): array { return array_values(array_filter(array_map( fn ($host) => strtolower(trim((string) $host)), (array) config('admin_access.hosts', []), ))); } /** Whether the console is bound to a hostname at all. */ public static function isHostBound(): bool { return self::hosts() !== []; } /** * Is this request addressed to the console? * * The one question the guards ask. When the console is host-bound the whole * host is the console — including its sign-in page, which is precisely what * the path test used to miss. */ public static function isConsole(Request $request): bool { return self::isHostBound() ? self::covers($request->getHost()) : $request->is(self::FALLBACK_PREFIX, self::FALLBACK_PREFIX.'/*'); } /** Is this hostname one the console answers on? */ public static function covers(string $host): bool { return in_array(strtolower($host), self::hosts(), true); } /** * The path prefix console routes are registered under. * * Empty when host-bound (the console is at the root of its own hostname), * `admin` otherwise. */ public static function prefix(): string { return self::isHostBound() ? '' : self::FALLBACK_PREFIX; } /** Where the console's own front page lives, as a path. */ public static function home(): string { return '/'.self::prefix(); } }