Hide fulfilled pending-setup orders from the customer hosting list.
Deploy Ladill Hosting / deploy (push) Successful in 45s
Deploy Ladill Hosting / deploy (push) Successful in 45s
Sales Centre left Active CustomerHostingOrder rows with pending-setup.local alongside real HostingAccounts, so customers saw two hostings. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -146,6 +146,53 @@ class CustomerHostingOrder extends Model
|
||||
return $query->where('user_id', $userId);
|
||||
}
|
||||
|
||||
/** Orders still awaiting payment, approval, or provisioning — not live accounts. */
|
||||
public function scopeInFlight($query)
|
||||
{
|
||||
return $query->whereIn('status', [
|
||||
self::STATUS_PENDING_PAYMENT,
|
||||
self::STATUS_PENDING_APPROVAL,
|
||||
self::STATUS_APPROVED,
|
||||
self::STATUS_PROVISIONING,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function isPlaceholderDomainName(?string $domain): bool
|
||||
{
|
||||
$domain = strtolower(trim((string) $domain));
|
||||
|
||||
return $domain === '' || $domain === 'pending-setup.local' || str_ends_with($domain, '.ladill.com');
|
||||
}
|
||||
|
||||
/**
|
||||
* Label for UI lists — never surface pending-setup.local when a real
|
||||
* hosting account / domain is available.
|
||||
*/
|
||||
public function displayDomainLabel(): string
|
||||
{
|
||||
if ($this->relationLoaded('hostingAccount') && $this->hostingAccount) {
|
||||
$account = $this->hostingAccount;
|
||||
if (! $account->relationLoaded('sites')) {
|
||||
$account->load('sites');
|
||||
}
|
||||
|
||||
$label = $account->linkedDomainLabel();
|
||||
if (filled($label) && ! static::isPlaceholderDomainName($label)) {
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
|
||||
if (! static::isPlaceholderDomainName($this->domain_name)) {
|
||||
return (string) $this->domain_name;
|
||||
}
|
||||
|
||||
if (filled($this->server_ip)) {
|
||||
return (string) $this->server_ip;
|
||||
}
|
||||
|
||||
return 'Domain pending';
|
||||
}
|
||||
|
||||
public function isPendingApproval(): bool
|
||||
{
|
||||
return $this->status === self::STATUS_PENDING_APPROVAL;
|
||||
|
||||
@@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use App\Services\Hosting\PlaceholderPrimaryDomainService;
|
||||
|
||||
class HostingAccount extends Model
|
||||
{
|
||||
@@ -139,7 +140,15 @@ class HostingAccount extends Model
|
||||
public function linkedDomainLabel(): ?string
|
||||
{
|
||||
if ($this->relationLoaded('sites') && $this->sites->isNotEmpty()) {
|
||||
$domains = $this->sites->pluck('domain')->filter()->unique()->values();
|
||||
$domains = $this->sites
|
||||
->pluck('domain')
|
||||
->filter(fn ($domain) => filled($domain) && ! PlaceholderPrimaryDomainService::isPlaceholderDomain((string) $domain))
|
||||
->unique()
|
||||
->values();
|
||||
|
||||
if ($domains->isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($domains->count() === 1) {
|
||||
return (string) $domains->first();
|
||||
@@ -152,7 +161,11 @@ class HostingAccount extends Model
|
||||
: $preview;
|
||||
}
|
||||
|
||||
return filled($this->primary_domain) ? (string) $this->primary_domain : null;
|
||||
if (filled($this->primary_domain) && ! PlaceholderPrimaryDomainService::isPlaceholderDomain($this->primary_domain)) {
|
||||
return (string) $this->primary_domain;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function databases(): HasMany
|
||||
|
||||
Reference in New Issue
Block a user