123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\common\model;
- use think\Db;
- class DeviceForm extends Base
- {
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public $table = 'device_form';
- protected $validateName = 'DeviceForm';
- public function updates(){
- $data = request()->post();
- $data['org_id'] =cur_org_id();
- $result = validate($this->validateName)->check($data,[],'');
- if(true !== $result){
- $this->error = validate($this->validateName)->getError();
- return false;
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $data['update_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- $this->error = '操作失败';
- return false;
- }
- return true;
- }
- /**
- * 获取检查项列表
- *
- * @author wst
- * @date 2021/9/6 11:27
- * @return array
- */
- public function list(){
- $where['del']=0;
- $where['enable']=1;
- $where['org_id']=cur_org_id();
- $list = $this->field('id,title')->where($where)->select()->toArray();
- return $list;
- }
- public function byCateList($cate_id){
- $where['del']=0;
- $where['enable']=1;
- $where['cate_id']=$cate_id;
- $where['org_id']=cur_org_id();
- $list = $this->field('id,title')->where($where)->select();
- return $list?$list->toArray():[];
- }
- }
|