hasMany(SsNodeLabel::class, 'node_id', 'id'); } public function auth(): HasOne { return $this->hasOne(NodeAuth::class, 'node_id', 'id'); } public function getLevelNameAttribute(): string { return Level::whereLevel($this->attributes['level'])->first()->name; } // Node查询,查用户所在分组Node权限 public function scopeGroupNodePermit($query, $group_id = 0) { $userGroup = UserGroup::find($group_id); if($userGroup){ $nodes = explode(',', $userGroup->nodes); if($nodes){ return $query->whereIn('id', $nodes); } } return $query; } public function getTypeLabelAttribute(): string { switch($this->attributes['type']){ case 1: $type_label = 'ShadowsocksR'; break; case 2: $type_label = 'V2Ray'; break; case 3: $type_label = 'Trojan'; break; case 4: $type_label = 'VNet'; break; default: $type_label = 'UnKnown'; } return $type_label; } }