'integer', ]; /** * 角色关联 */ public function roles(): BelongsToMany { return $this->belongsToMany(Role::class, 'role_permissions'); } /** * 按分组获取权限 */ public static function getGroupedPermissions() { return static::orderBy('group_name') ->orderBy('sort') ->get() ->groupBy('group_name'); } /** * 通过slug查找 */ public static function findBySlug(string $slug): ?self { return static::where('slug', $slug)->first(); } }