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>
66 lines
1.5 KiB
PHP
66 lines
1.5 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\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class HostedSite extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'hosting_account_id',
|
|
'domain_id',
|
|
'domain',
|
|
'document_root',
|
|
'type',
|
|
'status',
|
|
'php_version',
|
|
'ssl_enabled',
|
|
'ssl_status',
|
|
'ssl_error',
|
|
'ssl_expires_at',
|
|
'ssl_provisioned_at',
|
|
'installed_app',
|
|
'installed_app_version',
|
|
'app_config',
|
|
];
|
|
|
|
protected $casts = [
|
|
'ssl_enabled' => 'boolean',
|
|
'ssl_expires_at' => 'datetime',
|
|
'ssl_provisioned_at' => 'datetime',
|
|
'app_config' => 'array',
|
|
];
|
|
|
|
public function account(): BelongsTo
|
|
{
|
|
return $this->belongsTo(HostingAccount::class, 'hosting_account_id');
|
|
}
|
|
|
|
public function domain(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Domain::class);
|
|
}
|
|
|
|
public function databases(): HasMany
|
|
{
|
|
return $this->hasMany(HostedDatabase::class);
|
|
}
|
|
|
|
public function appInstallation(): HasOne
|
|
{
|
|
return $this->hasOne(AppInstallation::class)->where('status', 'active')->latestOfMany();
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('status', 'active');
|
|
}
|
|
}
|