edit.lt 655 B

1234567891011121314151617181920
  1. //编辑
  2. public function edit(){
  3. $id = $this->request->param('id');
  4. $info = $this->model->find($id);
  5. $post = CommonFun::filterPostData($this->request->post());{%validate%}{%adminUserId%}{%uploadDomainFields%}{%unsetFields%}
  6. foreach ($post as $k => $v) {
  7. $info->$k = $v;
  8. }
  9. try {
  10. $updateRes = $info->save();
  11. if ($updateRes) {
  12. return $this->success('编辑成功');
  13. } else {
  14. return $this->error('操作失败');
  15. }
  16. } catch (\Exception $e) {
  17. return $this->exceptionError($e);
  18. }
  19. }