From fb55edeedb8e0107783bf06182cd69c9295fcf4b Mon Sep 17 00:00:00 2001 From: eiixy <990656271@qq.com> Date: Fri, 11 Dec 2020 11:18:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B9=8B=E5=89=8D=E9=81=97?= =?UTF-8?q?=E7=95=99=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rbac.php | 7 ------- src/RbacUser.php | 52 ------------------------------------------------ 2 files changed, 59 deletions(-) delete mode 100644 src/Rbac.php delete mode 100644 src/RbacUser.php diff --git a/src/Rbac.php b/src/Rbac.php deleted file mode 100644 index b919284..0000000 --- a/src/Rbac.php +++ /dev/null @@ -1,7 +0,0 @@ -hasMany(UserRole::class); - } - - public function getPermissionAttrbute() - { - $roles = $this->roles; - return static::permission($roles); - } - - public static function permission($roles) - { - sort($roles); - $last_update = Role::query()->whereIn('id', $roles)->max('updated_at'); - $cache_key = implode('-', $roles) . '/' . strtotime($last_update); - - $permission = Cache::remember($cache_key, 60, function () use ($roles) { - $ids = RolePermissions::query()->whereIn('role_id', $roles)->pluck('permission_id'); - $keywords = Permission::query()->whereIn('id', $ids)->pluck('keyword')->map(function ($keyword) { - if ($keyword) { - return explode(',', $keyword); - } - })->collapse()->toArray(); - - $menu = Permission::with('children.children') - ->where('pid', 0) - ->whereIn('id', $ids) - ->whereIn('type', [Permission::TYPE_CATALOG, Permission::TYPE_PAGE]) - ->get()->toArray(); - return [ - 'permissions' => $keywords, - 'menu' => $menu - ]; - }); - - return $permission; - } - - -}