角色和子角色一起删除

Fix #20
This commit is contained in:
walkor 2023-03-04 19:36:08 +08:00 committed by GitHub
parent 89680d3754
commit f128cb7e6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -171,6 +171,11 @@ class RoleController extends Crud
if (!Auth::isSupperAdmin() && array_diff($ids, Auth::getScopeRoleIds())) {
return $this->json(1, '无删除权限');
}
$tree = new Tree(Role::get());
$descendants = $tree->getDescendant($ids);
if ($descendants) {
$ids = array_merge($ids, array_column($descendants, 'id'));
}
$this->doDelete($ids);
return $this->json(0);
}