...
|
...
|
@@ -4,6 +4,11 @@ namespace app\admin\controller\user; |
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use app\common\library\Auth;
|
|
|
use think\Db;
|
|
|
use think\Exception;
|
|
|
use think\exception\DbException;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
|
|
|
|
|
/**
|
|
|
* 会员管理
|
...
|
...
|
@@ -82,7 +87,43 @@ class User extends Backend |
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
$this->view->assign('groupList', build_select('row[group_id]', \app\admin\model\UserGroup::column('id,name'), $row['group_id'], ['class' => 'form-control selectpicker']));
|
|
|
return parent::edit($ids);
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
if (false === $this->request->isPost()) {
|
|
|
$this->view->assign('row', $row);
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
$params = $this->request->post('row/a');
|
|
|
if (empty($params)) {
|
|
|
$this->error(__('Parameter %s can not be empty', ''));
|
|
|
}
|
|
|
$params = $this->preExcludeFields($params);
|
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
//是否采用模型验证
|
|
|
if ($this->modelValidate) {
|
|
|
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
|
if ($params['is_teach'] == 1){
|
|
|
$params['teach_phone'] = $params['mobile'];
|
|
|
}else{
|
|
|
$params['teach_phone'] = null;
|
|
|
}
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if (false === $result) {
|
|
|
$this->error(__('No rows were updated'));
|
|
|
}
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|