VPS and dedicated server ordering, managed panels, SSO, billing, and launcher integration — forked from hosting infrastructure with server-focused routes and dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
1.9 KiB
PHP
76 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
class HostingPlanChange extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
public const DIRECTION_UPGRADE = 'upgrade';
|
|
public const DIRECTION_DOWNGRADE = 'downgrade';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'hosting_account_id',
|
|
'from_hosting_product_id',
|
|
'to_hosting_product_id',
|
|
'direction',
|
|
'billing_cycle',
|
|
'cycle_months',
|
|
'remaining_days',
|
|
'proration_ratio',
|
|
'old_cycle_price',
|
|
'new_cycle_price',
|
|
'charge_amount',
|
|
'credit_amount',
|
|
'net_amount',
|
|
'currency',
|
|
'status',
|
|
'applied_at',
|
|
'metadata',
|
|
];
|
|
|
|
protected $casts = [
|
|
'cycle_months' => 'integer',
|
|
'remaining_days' => 'integer',
|
|
'proration_ratio' => 'decimal:4',
|
|
'old_cycle_price' => 'decimal:2',
|
|
'new_cycle_price' => 'decimal:2',
|
|
'charge_amount' => 'decimal:2',
|
|
'credit_amount' => 'decimal:2',
|
|
'net_amount' => 'decimal:2',
|
|
'applied_at' => 'datetime',
|
|
'metadata' => 'array',
|
|
];
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function account(): BelongsTo
|
|
{
|
|
return $this->belongsTo(HostingAccount::class, 'hosting_account_id');
|
|
}
|
|
|
|
public function fromProduct(): BelongsTo
|
|
{
|
|
return $this->belongsTo(HostingProduct::class, 'from_hosting_product_id');
|
|
}
|
|
|
|
public function toProduct(): BelongsTo
|
|
{
|
|
return $this->belongsTo(HostingProduct::class, 'to_hosting_product_id');
|
|
}
|
|
|
|
public function invoice(): HasOne
|
|
{
|
|
return $this->hasOne(HostingBillingInvoice::class);
|
|
}
|
|
}
|