Deploy Ladill Hosting / deploy (push) Successful in 51s
Use the Domains API for owned domains across panel, account, and order forms, with an embedded iframe purchase modal instead of redirecting to domains.ladill.com. Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Domains;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class LadillDomainsClient
|
|
{
|
|
/** @return list<string> */
|
|
public function ownedForUser(string $publicId): array
|
|
{
|
|
$key = (string) (config('domains.api_key') ?? '');
|
|
if ($key === '') {
|
|
return [];
|
|
}
|
|
|
|
try {
|
|
$res = Http::withToken($key)
|
|
->acceptJson()
|
|
->timeout(10)
|
|
->get(rtrim((string) config('domains.api_url'), '/').'/owned-domains', [
|
|
'user' => $publicId,
|
|
]);
|
|
|
|
$res->throw();
|
|
|
|
return collect($res->json('data', []))
|
|
->map(fn ($d) => strtolower(trim((string) $d)))
|
|
->filter()
|
|
->values()
|
|
->all();
|
|
} catch (\Throwable $e) {
|
|
Log::warning('LadillDomainsClient: could not load owned domains', [
|
|
'user' => $publicId,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
|
|
return [];
|
|
}
|
|
}
|
|
}
|