Wire Ladill domain picker and purchase modal into hosting flows.
Deploy Ladill Hosting / deploy (push) Successful in 51s
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>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?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 [];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user