Extract Ladill Servers as standalone app at servers.ladill.com.
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>
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class VpsInstance extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'hosting_plan_id',
|
||||
'name',
|
||||
'hostname',
|
||||
'provider',
|
||||
'provider_instance_id',
|
||||
'ip_address',
|
||||
'ipv6_address',
|
||||
'region',
|
||||
'datacenter',
|
||||
'image',
|
||||
'cpu_cores',
|
||||
'ram_mb',
|
||||
'disk_gb',
|
||||
'status',
|
||||
'power_status',
|
||||
'root_password_encrypted',
|
||||
'ssh_public_key',
|
||||
'tags',
|
||||
'metadata',
|
||||
'provisioned_at',
|
||||
'expires_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'tags' => 'array',
|
||||
'metadata' => 'array',
|
||||
'provisioned_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
];
|
||||
|
||||
protected $hidden = ['root_password_encrypted'];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function plan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(HostingPlan::class, 'hosting_plan_id');
|
||||
}
|
||||
|
||||
public function snapshots(): HasMany
|
||||
{
|
||||
return $this->hasMany(VpsSnapshot::class);
|
||||
}
|
||||
|
||||
public function isRunning(): bool
|
||||
{
|
||||
return $this->status === 'running';
|
||||
}
|
||||
|
||||
public function scopeRunning($query)
|
||||
{
|
||||
return $query->where('status', 'running');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user