Burst.php 919 B

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