Files
nexusphp/app/Models/AgentAllow.php

45 lines
1.2 KiB
PHP
Raw Normal View History

2021-04-02 19:48:41 +08:00
<?php
namespace App\Models;
2025-07-21 20:55:30 +07:00
use App\Enums\ModelEventEnum;
2021-04-02 19:48:41 +08:00
class AgentAllow extends NexusModel
{
protected $table = 'agent_allowed_family';
protected $fillable = [
2021-04-16 19:04:01 +08:00
'family', 'start_name', 'exception', 'allowhttps', 'comment',
2021-04-02 19:48:41 +08:00
'peer_id_pattern', 'peer_id_match_num', 'peer_id_matchtype', 'peer_id_start',
'agent_pattern', 'agent_match_num', 'agent_matchtype', 'agent_start',
];
2022-02-25 18:09:31 +08:00
const MATCH_TYPE_DEC = 'dec';
const MATCH_TYPE_HEX = 'hex';
public static $matchTypes = [
self::MATCH_TYPE_DEC => 'dec',
self::MATCH_TYPE_HEX => 'hex',
];
2025-07-21 20:55:30 +07:00
protected static function booted()
{
static::created(function ($model) {
fire_event(ModelEventEnum::AGENT_ALLOW_CREATED, $model);
});
static::updated(function ($model) {
fire_event(ModelEventEnum::AGENT_ALLOW_UPDATED, $model);
});
static::deleted(function ($model) {
fire_event(ModelEventEnum::AGENT_ALLOW_DELETED, $model);
});
}
2022-02-25 18:09:31 +08:00
public function denies(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(AgentDeny::class, 'family_id');
}
2021-04-02 19:48:41 +08:00
}