75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\HasUuid;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Instance extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\InstanceFactory> */
|
|
use HasFactory, HasUuid;
|
|
|
|
protected $fillable = [
|
|
'customer_id', 'order_id', 'host_id', 'vmid', 'guest_ip', 'plan', 'quota_gb', 'disk_gb',
|
|
'ram_mb', 'cores', 'subdomain', 'custom_domain', 'nc_admin_ref',
|
|
'route_written', 'cert_ok', 'status', 'cancel_requested_at', 'service_ends_at',
|
|
];
|
|
|
|
protected $hidden = ['nc_admin_ref'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'nc_admin_ref' => 'encrypted',
|
|
'route_written' => 'boolean',
|
|
'cert_ok' => 'boolean',
|
|
'vmid' => 'integer',
|
|
'quota_gb' => 'integer',
|
|
'disk_gb' => 'integer',
|
|
'ram_mb' => 'integer',
|
|
'cores' => 'integer',
|
|
'cancel_requested_at' => 'datetime',
|
|
'service_ends_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function order(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Order::class);
|
|
}
|
|
|
|
public function host(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Host::class);
|
|
}
|
|
|
|
public function dnsRecords(): HasMany
|
|
{
|
|
return $this->hasMany(DnsRecord::class);
|
|
}
|
|
|
|
public function backups(): HasMany
|
|
{
|
|
return $this->hasMany(Backup::class);
|
|
}
|
|
|
|
public function monitoringTargets(): HasMany
|
|
{
|
|
return $this->hasMany(MonitoringTarget::class);
|
|
}
|
|
|
|
public function onboardingTasks(): HasMany
|
|
{
|
|
return $this->hasMany(OnboardingTask::class);
|
|
}
|
|
}
|