Initial Ladill Hosting app with Gitea deploy pipeline.
Deploy Ladill Hosting / deploy (push) Failing after 17s
Deploy Ladill Hosting / deploy (push) Failing after 17s
Shared web hosting extracted from the platform monolith, with CI deploy to /var/www/ladill-hosting matching Bird/Domains/Email. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
|
||||
class DomainOrder extends Model
|
||||
{
|
||||
public const TYPE_REGISTRATION = 'registration';
|
||||
public const TYPE_TRANSFER = 'transfer';
|
||||
public const TYPE_RENEWAL = 'renewal';
|
||||
|
||||
public const REGISTRAR_DYNADOT = 'dynadot';
|
||||
public const REGISTRAR_RESELLERCLUB = 'resellerclub';
|
||||
|
||||
public const STATUS_CART = 'cart';
|
||||
public const STATUS_PENDING_PAYMENT = 'pending_payment';
|
||||
public const STATUS_PENDING = 'pending';
|
||||
public const STATUS_PENDING_CUSTOMER_REGISTRATION = 'pending_customer_registration';
|
||||
public const STATUS_PROCESSING = 'processing';
|
||||
public const STATUS_COMPLETED = 'completed';
|
||||
public const STATUS_FAILED = 'failed';
|
||||
public const STATUS_CANCELLED = 'cancelled';
|
||||
|
||||
public const PAYMENT_UNPAID = 'unpaid';
|
||||
public const PAYMENT_PENDING = 'pending';
|
||||
public const PAYMENT_PAID = 'paid';
|
||||
public const PAYMENT_FAILED = 'failed';
|
||||
public const PAYMENT_REFUNDED = 'refunded';
|
||||
|
||||
public const FULFILLMENT_CART = 'cart';
|
||||
public const FULFILLMENT_PAYMENT_PENDING = 'payment_pending';
|
||||
public const FULFILLMENT_PAYMENT_RECEIVED = 'payment_received';
|
||||
public const FULFILLMENT_SUBMITTING = 'submitting';
|
||||
public const FULFILLMENT_AWAITING_REGISTRAR = 'awaiting_registrar';
|
||||
public const FULFILLMENT_FULFILLED = 'fulfilled';
|
||||
public const FULFILLMENT_FAILED = 'failed';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'domain_name',
|
||||
'order_type',
|
||||
'registrar',
|
||||
'status',
|
||||
'payment_status',
|
||||
'fulfillment_status',
|
||||
'amount_minor',
|
||||
'currency',
|
||||
'years',
|
||||
'payment_reference',
|
||||
'auth_code_encrypted',
|
||||
'contact_info',
|
||||
'nameservers',
|
||||
'registrar_order_id',
|
||||
'meta',
|
||||
'paid_at',
|
||||
'submitted_at',
|
||||
'completed_at',
|
||||
'expires_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'amount_minor' => '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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user