设置角色组
This commit is contained in:
@@ -84,6 +84,33 @@ class User extends Backend
|
||||
return parent::edit($ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角色组
|
||||
*/
|
||||
public function group($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$this->token();
|
||||
$params = $this->request->post('row/a');
|
||||
$groupId = isset($params['group_id']) ? intval($params['group_id']) : 0;
|
||||
if (!$groupId || !\app\admin\model\UserGroup::get($groupId)) {
|
||||
$this->error('请选择角色组');
|
||||
}
|
||||
$result = $row->allowField(['group_id'])->save(['group_id' => $groupId]);
|
||||
if ($result === false) {
|
||||
$this->error('角色组保存失败');
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
$this->view->assign('row', $row);
|
||||
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user