'integer', 'years' => 'integer', 'contact_info' => 'array', 'nameservers' => 'array', 'meta' => 'array', 'paid_at' => 'datetime', 'submitted_at' => 'datetime', 'completed_at' => 'datetime', 'expires_at' => 'datetime', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } public function setAuthCode(string $authCode): void { $this->auth_code_encrypted = Crypt::encryptString($authCode); } public function getAuthCode(): ?string { if (empty($this->auth_code_encrypted)) { return null; } try { return Crypt::decryptString($this->auth_code_encrypted); } catch (\Exception $e) { return null; } } public function getTld(): string { $parts = explode('.', $this->domain_name, 2); return $parts[1] ?? ''; } public function formatAmount(): string { $amount = $this->amount_minor / 100; $symbol = $this->currency === 'GHS' ? 'GH₵' : $this->currency; return $symbol . number_format($amount, 2); } public function getOrderTypeLabel(): string { return match ($this->order_type) { self::TYPE_REGISTRATION => 'Registration', self::TYPE_TRANSFER => 'Transfer', self::TYPE_RENEWAL => 'Renewal', default => ucfirst($this->order_type), }; } public function getStatusLabel(): string { return match ($this->status) { self::STATUS_CART => 'In Cart', self::STATUS_PENDING_PAYMENT => 'Awaiting Payment', self::STATUS_PENDING => 'Pending', self::STATUS_PENDING_CUSTOMER_REGISTRATION => 'Awaiting Registration', self::STATUS_PROCESSING => 'Processing', self::STATUS_COMPLETED => 'Completed', self::STATUS_FAILED => 'Failed', self::STATUS_CANCELLED => 'Cancelled', default => ucfirst($this->status), }; } public function isInCart(): bool { return in_array($this->status, [self::STATUS_CART, self::STATUS_PENDING_PAYMENT]); } public function isPaid(): bool { return $this->payment_status === self::PAYMENT_PAID; } public function scopeInCart($query) { return $query->whereIn('status', [self::STATUS_CART, self::STATUS_PENDING_PAYMENT]); } public function scopeForUser($query, User $user) { return $query->where('user_id', $user->id); } public function scopePendingFulfillment($query) { return $query->where('payment_status', self::PAYMENT_PAID) ->whereIn('fulfillment_status', [ self::FULFILLMENT_PAYMENT_RECEIVED, self::FULFILLMENT_SUBMITTING, self::FULFILLMENT_AWAITING_REGISTRAR, ]); } }