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']); $carportId = explode(',',$data['carport_id']); $data['carport_id'] = $carportId[count($carportId)-1]; 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; } public function getList(){ $list =$this ->where('org_id',cur_org_id()) ->where('del',0) ->select() ->toArray(); return $list; } public function tree(){ $area = (new HouseAreas())->getList(); foreach ($area as $k=>$v){ $area[$k]['child'] = Db::name('house') ->where('org_id',cur_org_id()) ->where('area_id',$v['id']) ->where('enable',1) ->where('del',0) ->where('type',3) ->where('cate',5) ->select(); } return $area; } }