GreenForm.php 1.1 KB

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