mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 14:36:17 +00:00
Refactor firewall and add edit rule (#488)
This commit is contained in:
@ -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';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user