Add saved firewall configuration functionality
- Implemented the ability to save, view, apply, and delete firewall configurations for users. - Created a new model for FirewallConfiguration and corresponding database migration. - Enhanced the firewall view to include a tab for managing saved configurations.
This commit is contained in:
50
extensions/Servers/Proxmox/Models/FirewallConfiguration.php
Normal file
50
extensions/Servers/Proxmox/Models/FirewallConfiguration.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Servers\Proxmox\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class FirewallConfiguration extends Model
|
||||
{
|
||||
protected $table = 'ext_proxmox_firewall_configurations';
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'configuration_name',
|
||||
'firewall_rules',
|
||||
'incoming_policy',
|
||||
'outgoing_policy',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'firewall_rules' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the user that owns this firewall configuration.
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include configurations for a specific user.
|
||||
*/
|
||||
public function scopeForUser($query, int $userId)
|
||||
{
|
||||
return $query->where('user_id', $userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rules count for display.
|
||||
*/
|
||||
public function getRulesCountAttribute(): int
|
||||
{
|
||||
return is_array($this->firewall_rules) ? count($this->firewall_rules) : 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user