Skip to content

Commit 8e84c63

Browse files
authored
添加 超级管理员 默认全部规则
1 parent b1916f2 commit 8e84c63

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/Traits/User.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,19 @@ public function isSuper()
104104
* @return void
105105
*/
106106
public function getAllPermissions(): Collection
107-
{
107+
{
108+
// 超级管理员 默认全部规则
109+
if ($this->isSuper()) {
110+
return Permission::select();
111+
}
112+
108113
$permissions = [];
114+
109115
foreach ($this->roles as $role) {
110116
$permissions = array_unique(array_merge($permissions, $role->permissions->column('name')));
111117
}
112118

113119
$permissions = Permission::whereIn('name', implode(',', $permissions))->select();
114-
115120
return $permissions;
116121
}
117122
}

0 commit comments

Comments
 (0)