30c2f655e7
统一将节点编辑和批量修改的 group_ids、route_ids 序列化为字符串 ID,避免保存权限组后订阅侧无法命中节点 后端新增 whereGroupId 兼容历史字符串与数字 JSON 值, 并补齐 TUIC 版本、ALPN 选项及 AnyTLS 默认 Padding 配置 docs: 新增 HelloAGENTS 通用与工作流避坑指南
47 lines
1020 B
PHP
Executable File
47 lines
1020 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
/**
|
|
* App\Models\ServerGroup
|
|
*
|
|
* @property int $id
|
|
* @property string $name 分组名
|
|
* @property int $created_at
|
|
* @property int $updated_at
|
|
* @property-read int $server_count 服务器数量
|
|
*/
|
|
class ServerGroup extends Model
|
|
{
|
|
protected $table = 'v2_server_group';
|
|
protected $dateFormat = 'U';
|
|
protected $casts = [
|
|
'created_at' => 'timestamp',
|
|
'updated_at' => 'timestamp'
|
|
];
|
|
|
|
public function users(): HasMany
|
|
{
|
|
return $this->hasMany(User::class, 'group_id', 'id');
|
|
}
|
|
|
|
public function servers()
|
|
{
|
|
return Server::whereGroupId($this->id)->get();
|
|
}
|
|
|
|
/**
|
|
* 获取服务器数量
|
|
*/
|
|
protected function serverCount(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: fn () => Server::whereGroupId($this->id)->count(),
|
|
);
|
|
}
|
|
}
|