新增角色部门

This commit is contained in:
yanwenwu
2020-01-12 12:54:59 +08:00
parent 7c09bcf0cf
commit 1b7cc3fcf5
5 changed files with 108 additions and 2 deletions

View File

@@ -51,6 +51,9 @@ class Role extends CatchController
if (!empty($request->param('permissions'))) {
$this->role->attach($request->param('permissions'));
}
if (!empty($request->param('departments'))) {
$this->role->attachDepartments($request->param('departments'));
}
// 添加角色
return CatchResponse::success();
}
@@ -59,6 +62,7 @@ class Role extends CatchController
{
$role = $this->role->findBy($id);
$role->permissions = $role->getPermissions();
$role->departments = $role->getDepartments();
return CatchResponse::success($role);
}
@@ -91,7 +95,10 @@ class Role extends CatchController
if (!empty($request->param('permissions'))) {
$role->attach($request->param('permissions'));
}
if (!empty($request->param('departments'))) {
$role->detachDepartments();
$role->attach($request->param('departments'));
}
return CatchResponse::success();
}
@@ -113,6 +120,8 @@ class Role extends CatchController
$role = $this->role->findBy($id);
// 删除权限
$role->detach();
// 删除部门关联
$role->detachDepartments();
// 删除用户关联
$role->users()->detach();
// 删除