0
0

HouseAreas.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class HouseAreas extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. protected $updateTime = 'update_time';
  8. public $table = 'house_areas';
  9. protected $validateName = 'HouseAreas';
  10. public function updates(){
  11. $data = request()->post();
  12. $data['org_id'] =cur_org_id();
  13. $result = validate($this->validateName)->check($data,[],'');
  14. if(true !== $result){
  15. $this->error = validate($this->validateName)->getError();
  16. return false;
  17. }
  18. $id = $data['id'];
  19. if(!empty($data['latlng'])){
  20. $latLng = explode('-',$data['latlng']);
  21. $data['lat'] = $latLng[0];
  22. $data['lng'] = $latLng[1];
  23. }
  24. unset($data['id'],$data['latlng']);
  25. if($id > 0){
  26. $data['update_time'] = date('Y-m-d H:i:s');
  27. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  28. }else{
  29. $data['create_time'] = date('Y-m-d H:i:s');
  30. $ret = $this->allowField(true)->save($data);
  31. }
  32. if(!$ret){
  33. $this->error = '操作失败';
  34. return false;
  35. }
  36. return true;
  37. }
  38. public function getList(){
  39. $list =$this
  40. ->where('org_id',cur_org_id())
  41. ->where('del',0)
  42. ->select()
  43. ->toArray();
  44. return $list;
  45. }
  46. }