Deploy Ladill Link / deploy (push) Successful in 37s
Add Bitly-style branded domain support via Ladill Domains SSL API, account analytics dashboard, settings page with default domain picker, and fix SSO/dashboard issues from QR Plus template leftovers. Co-authored-by: Cursor <cursoragent@cursor.com>
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Customer-branded short-link domain (e.g. go.brand.com) for Ladill Link.
|
|
*/
|
|
class LinkCustomDomain extends Model
|
|
{
|
|
public const STATUS_PENDING = 'pending';
|
|
|
|
public const STATUS_ACTIVE = 'active';
|
|
|
|
public const STATUS_FAILED = 'failed';
|
|
|
|
protected $fillable = [
|
|
'user_id', 'host', 'include_www', 'is_default', 'status', 'ssl_status',
|
|
'dns_verified_at', 'ssl_issued_at', 'ssl_expires_at', 'last_error',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'include_www' => 'boolean',
|
|
'is_default' => 'boolean',
|
|
'dns_verified_at' => 'datetime',
|
|
'ssl_issued_at' => 'datetime',
|
|
'ssl_expires_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public function baseUrl(): string
|
|
{
|
|
return 'https://'.$this->host;
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::saving(function (LinkCustomDomain $domain) {
|
|
$domain->host = strtolower(trim((string) $domain->host, " \t\n\r\0\x0B./"));
|
|
$domain->host = preg_replace('/^www\./', '', $domain->host) ?: $domain->host;
|
|
});
|
|
}
|
|
}
|