|
@@ -89,7 +89,6 @@ class Raprize extends Backend
|
|
}
|
|
}
|
|
$params = $this->preExcludeFields($params);
|
|
$params = $this->preExcludeFields($params);
|
|
$ra_id=session('ra_id');
|
|
$ra_id=session('ra_id');
|
|
-
|
|
|
|
$params['r_id']=$ra_id;
|
|
$params['r_id']=$ra_id;
|
|
$raffle = \app\admin\model\Raffle::getById($ra_id);
|
|
$raffle = \app\admin\model\Raffle::getById($ra_id);
|
|
$params['r_name']=$raffle->name;
|
|
$params['r_name']=$raffle->name;
|
|
@@ -122,4 +121,55 @@ class Raprize extends Backend
|
|
}
|
|
}
|
|
$this->success();
|
|
$this->success();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function edit($ids = null)
|
|
|
|
+ {
|
|
|
|
+ $row = $this->model->get($ids);
|
|
|
|
+ if (!$row) {
|
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
|
+ }
|
|
|
|
+ $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);
|
|
|
|
+ $ra_id=session('ra_id');
|
|
|
|
+ $params['r_id']=$ra_id;
|
|
|
|
+ $raffle = \app\admin\model\Raffle::getById($ra_id);
|
|
|
|
+ $params['r_name']=$raffle->name;
|
|
|
|
+ $category=\app\common\model\Category::getById($params['t_type']);
|
|
|
|
+ $params['t_type_name']=$category->name;
|
|
|
|
+ $prize=\app\admin\model\Prize::getById($params['p_id']);
|
|
|
|
+ $params['p_name']=$prize->name;
|
|
|
|
+ $params['price']=$prize->price;
|
|
|
|
+ $params['money']=$prize->money;
|
|
|
|
+ $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);
|
|
|
|
+ }
|
|
|
|
+ $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();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|