Deploy Ladill Merchant / deploy (push) Successful in 29s
Customers can connect their own domain to a merchant page (storefront/event): add a domain, point an A record (apex + www) to the app server, click Verify — DNS is checked, then Ladill Domains' central SSL service issues + installs the Let's Encrypt cert and calls back to flip it live. The custom domain then serves the mapped page (host resolution on /). Feature-gated: only active when a Domains SSL API key is set, so this deploy is inert until wired. - custom_domains table + CustomDomain model - CustomDomainService (DNS verify, request cert), DomainsSslClient, DnsResolver - settings UI panel, signed SSL callback receiver, host resolution on / - feature tests (DNS verify/fail, signed callback, ownership) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* A customer's own domain (e.g. brand.com) pointed at one storefront (QrCode).
|
|
* Visiting the domain serves that storefront's public page. DNS is verified to
|
|
* resolve to the app, then Ladill Domains issues + installs the TLS cert.
|
|
*/
|
|
class CustomDomain extends Model
|
|
{
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_ACTIVE = 'active';
|
|
public const STATUS_FAILED = 'failed';
|
|
|
|
protected $fillable = [
|
|
'qr_code_id', 'user_id', 'host', 'include_www', 'status', 'ssl_status',
|
|
'dns_verified_at', 'ssl_issued_at', 'ssl_expires_at', 'last_error',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'include_www' => 'boolean',
|
|
'dns_verified_at' => 'datetime',
|
|
'ssl_issued_at' => 'datetime',
|
|
'ssl_expires_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function qrCode(): BelongsTo
|
|
{
|
|
return $this->belongsTo(QrCode::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isLive(): bool
|
|
{
|
|
return $this->status === self::STATUS_ACTIVE && $this->ssl_status === self::STATUS_ACTIVE;
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (CustomDomain $d) {
|
|
$d->host = strtolower(trim((string) $d->host, " \t\n\r\0\x0B./"));
|
|
$d->host = preg_replace('/^www\./', '', $d->host) ?: $d->host;
|
|
});
|
|
}
|
|
}
|