|
|
@@ -20,15 +20,21 @@ class District extends Model |
|
|
|
|
|
|
|
public function getChildren($adcode) |
|
|
|
{ |
|
|
|
|
|
|
|
return $this->where('parent_id', $adcode)->field('adcode as value,name as label')->select(); |
|
|
|
} |
|
|
|
|
|
|
|
public function province() |
|
|
|
{ |
|
|
|
$result = $this->where('level', '1')->field('adcode as value,name as label')->select(); |
|
|
|
//$result = $this->where('level','1')->field('adcode as value,name as label')->select(); |
|
|
|
$result = $this->where('level','1')->where('level','2')->field('adcode as value,name as label')->select(); |
|
|
|
foreach ($result as $k => $v) { |
|
|
|
$result[$k]['children'] = $this->getChildren($v['value']); |
|
|
|
//市 |
|
|
|
if($v['value']==1) { |
|
|
|
$result[$k]['children'] = $this->getChildren($v['value']); |
|
|
|
}elseif($v['value']==2){ |
|
|
|
//区 |
|
|
|
$result[$k]['District'] = $this->getChildren($v['value']); |
|
|
|
} |
|
|
|
} |
|
|
|
$result = ['rows' => $result]; |
|
|
|
return $result; |