0
0

QualityForm.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class QualityForm extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. protected $updateTime = 'update_time';
  8. public $table = 'quality_form';
  9. protected $validateName = 'QualityForm';
  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. /**
  38. * 获取指定mode检查项
  39. *
  40. * @author wst
  41. * @date 2021/9/7 15:15
  42. * @return array
  43. */
  44. public function getByModeList(){
  45. $list =$this
  46. ->where('org_id',cur_org_id())
  47. ->where('del',0)
  48. ->where('enable',1)
  49. ->select()
  50. ->toArray();
  51. return $list;
  52. }
  53. }