Feedback.php 867 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class Feedback extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. public function updates(){
  8. $data = request()->post();
  9. $result = validate('Feedback')->check($data,[],'');
  10. if(true !== $result){
  11. $this->error = validate('Feedback')->getError();
  12. return false;
  13. }
  14. $id = $data['id'];
  15. unset($data['id']);
  16. if($id > 0){
  17. $data['to_user_id'] = is_login();
  18. $data['status'] = 1;
  19. $data['update_time'] = date('Y-m-d H:i:s');
  20. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  21. }else{
  22. $ret = $this->allowField(true)->save($data);
  23. }
  24. if(!$ret){
  25. $this->error = '操作失败';
  26. return false;
  27. }
  28. return true;
  29. }
  30. }