Commit 7c95becf authored by hujun's avatar hujun

修改获取江浙沪城市和区

parent d5a80fd7
...@@ -65,14 +65,20 @@ class Regions extends Model ...@@ -65,14 +65,20 @@ class Regions extends Model
} }
/** /**
* 获取江浙沪城市 * 获取江浙沪城市和区
* *
* @return false|\PDOStatement|string|\think\Collection * @return array
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getRegionsCity() { public function getRegionsCity() {
return $this->field('fullName')->where('parentCode in (310000, 320000, 330000)')->select(); $data = [];
$city_data = $this->field('code,fullName')->where('parentCode in (310000, 320000, 330000)')->select();
foreach ($city_data as $k=>$v) {
$data[$k]['name'] = $v['fullName'];
$data[$k]['city'] = $this->where('parentCode',$v['code'])->column('fullName');
}
return $data;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment