Files
portal-api/app/Models/DnsServer.php
T
baodev0 d6d63e5152 feat: Implement Plesk domain and hosting services
- Added PleskDomainService for managing domain operations (create, update, remove, get info).
- Introduced PleskHostingService for provisioning hosting accounts and notifying customers.
- Created PleskService for handling API requests to Plesk.
- Added migration to include 'type' column in dns_manager_servers table.
- Created migration for module_hosting_accounts table to track hosting subscriptions.
- Created migration for module_hosting_plesk_clients table to manage Plesk client credentials.
- Added email templates for notifying customers and admins about hosting account creation.
2026-08-06 17:24:01 +07:00

47 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use App\Enums\Server\ServerType;
use App\Traits\LogsActivity;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class DnsServer extends Model
{
use HasFactory, LogsActivity;
protected $table = 'dns_manager_servers';
protected $fillable = [
'name',
'ip_address',
'password',
'username',
'api_key',
'status',
'type',
];
public function getStatus(): string
{
return match ($this->attributes['status']) {
'activated' => '<span class="badge bg-success text-success-fg">Activated</span>',
'Stopped' => '<span class="badge bg-danger text-danger-fg">Stopped</span>',
default => '<span class="badge bg-secondary">Unknown</span>',
};
}
public function servesHosting(): bool
{
$type = $this->attributes['type'] ?? ServerType::DOMAIN->value;
return in_array($type, [ServerType::HOSTING->value, ServerType::BOTH->value], true);
}
protected function scopeIsActive($query)
{
return $query->where('status', 'activated');
}
}