12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\common\model;
- use think\Db;
- class HouseAreas extends Base
- {
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public $table = 'house_areas';
- protected $validateName = 'HouseAreas';
- 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'];
- if(!empty($data['latlng'])){
- $latLng = explode('-',$data['latlng']);
- $data['lat'] = $latLng[0];
- $data['lng'] = $latLng[1];
- }
- unset($data['id'],$data['latlng']);
- 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;
- }
- }
|