Files
portal-api/app/Models/DnsServer.php
T
baodev0 2deb4ad74e feat: Enhance service management and transaction handling
- Implemented client access token verification middleware to secure API endpoints.
- Updated ServiceController to fetch active hosting services for authenticated users.
- Refactored OrderController to ensure order retrieval is customer-specific.
- Improved error logging in VmController for unexpected vCenter responses.
- Disabled VNPay auto-deposit in TransactionController, switching to manual deposit flow.
- Enhanced ServiceClientDetailResource to include Plesk credentials for hosting accounts.
- Adjusted VpsServiceResource to dynamically set page type based on product type.
- Added logging for PowerShellService to capture errors in RDP port changes.
- Provisioning job now resolves service plans and logs relevant information for hosting accounts.
- Updated database migrations to add necessary fields for service plans and DNS servers.
- Refactored Service and ServicePlan models to establish relationships with hosting accounts and DNS servers.
2026-08-17 11:55:48 +07:00

48 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',
'panel_port',
'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');
}
}