Commit 1ff7cf56 authored by hujun's avatar hujun

根据区code获取省市区中文

parent d23d7ab0
...@@ -81,4 +81,22 @@ class Regions extends Model ...@@ -81,4 +81,22 @@ class Regions extends Model
} }
return $data; return $data;
} }
/**
* 根据区code获取省市区中文
*
* @param $code
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAddressByDiscCode($code) {
$disc = $this->field('code,parentCode,fullName')->where('code',$code)->find();
$city = $this->field('code,parentCode,fullName')->where('code',$disc['parentCode'])->find();
$province = $this->field('code,parentCode,fullName')->where('code',$city['parentCode'])->find();
$data = $province['fullName'] .'-'.$city['fullName'] .'-'.$disc['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