vito/app/Models/FirewallRule.php
Saeed Vaziry b2083fc6b2
Migrate to HTMX (#114)
Dropped Livewire
Added HTMX
Added Blade code lint
Drop Mysql and Redis
Migrate to SQLite
2024-03-06 17:02:59 +01:00

54 lines
1.0 KiB
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property int $server_id
* @property string $type
* @property string $protocol
* @property string $real_protocol
* @property int $port
* @property string $source
* @property ?string $mask
* @property string $note
* @property string $status
* @property Server $server
*/
class FirewallRule extends AbstractModel
{
use HasFactory;
protected $fillable = [
'server_id',
'type',
'protocol',
'port',
'source',
'mask',
'note',
'status',
];
protected $casts = [
'server_id' => 'integer',
'port' => 'integer',
];
protected $appends = [
'real_protocol',
];
public function server(): BelongsTo
{
return $this->belongsTo(Server::class);
}
public function getRealProtocolAttribute(): string
{
return $this->protocol === 'udp' ? 'udp' : 'tcp';
}
}