Active domain names owned by the account (lowercase). */ public function ownedForUser(string $publicId): array { [$storefront, $platform] = $this->fetchOwnedDomainsInParallel($publicId); return collect() ->merge($storefront) ->merge($platform) ->map(fn ($d) => strtolower(trim((string) $d))) ->filter() ->unique() ->sort() ->values() ->all(); } /** * @return array{0: list, 1: list} */ private function fetchOwnedDomainsInParallel(string $publicId): array { $storefront = []; $platform = []; try { $responses = Http::pool(function ($pool) use ($publicId) { $requests = []; $storefrontKey = (string) (config('domains.api_key') ?? ''); if ($storefrontKey !== '') { $requests['storefront'] = $pool->as('storefront') ->withToken($storefrontKey) ->acceptJson() ->timeout(10) ->get(rtrim((string) config('domains.api_url'), '/').'/owned-domains', [ 'user' => $publicId, ]); } $platformKey = (string) (config('domains.platform_api_key') ?? ''); if ($platformKey !== '') { $requests['platform'] = $pool->as('platform') ->withToken($platformKey) ->acceptJson() ->timeout(10) ->get(rtrim((string) config('domains.platform_api_url'), '/').'/owned-domains', [ 'user' => $publicId, ]); } return $requests; }); foreach ($responses as $name => $response) { if (! $response instanceof Response || ! $response->successful()) { continue; } $data = (array) $response->json('data', []); if ($name === 'storefront') { $storefront = $data; } elseif ($name === 'platform') { $platform = $data; } } } catch (\Throwable $e) { Log::warning('LadillDomainsClient: owned domains lookup failed', [ 'user' => $publicId, 'error' => $e->getMessage(), ]); } return [$storefront, $platform]; } }