Refactor firewall and add edit rule (#488)

This commit is contained in:
Richard Anderson
2025-02-16 19:31:58 +00:00
committed by GitHub
parent e2b9d18a71
commit 8c7c3d2192
23 changed files with 443 additions and 210 deletions

View File

@ -2,11 +2,13 @@
namespace App\Models;
use App\Enums\FirewallRuleStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $server_id
* @property string $name
* @property string $type
* @property string $protocol
* @property int $port
@ -21,6 +23,7 @@ class FirewallRule extends AbstractModel
use HasFactory;
protected $fillable = [
'name',
'server_id',
'type',
'protocol',
@ -36,13 +39,19 @@ class FirewallRule extends AbstractModel
'port' => 'integer',
];
public function getStatusColor(): string
{
return match ($this->status) {
FirewallRuleStatus::CREATING,
FirewallRuleStatus::UPDATING,
FirewallRuleStatus::DELETING => 'warning',
FirewallRuleStatus::READY => 'success',
FirewallRuleStatus::FAILED => 'danger',
};
}
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
public function getRealProtocol(): string
{
return $this->protocol === 'udp' ? 'udp' : 'tcp';
}
}