- 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.
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?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;
|
|
}
|
|
}
|