first commit
This commit is contained in:
38
application/common/service/City.php
Normal file
38
application/common/service/City.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +------------------------------------------------+
|
||||
// |http://www.cjango.com |
|
||||
// +------------------------------------------------+
|
||||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||||
// +------------------------------------------------+
|
||||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||||
// +------------------------------------------------+
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\City as CityModel;
|
||||
use app\common\model\Province as ProvinceModel;
|
||||
|
||||
class City extends _Init
|
||||
{
|
||||
public static function getData($id)
|
||||
{
|
||||
$list = CityModel::where('province_id', $id)->select();
|
||||
$opt = '';
|
||||
foreach ($list as $key => $val) {
|
||||
$opt .= "<option value='{$val['name']}' ";
|
||||
$opt .= " >{$val['name']}</option>";
|
||||
}
|
||||
echo $opt;
|
||||
}
|
||||
|
||||
public static function getCity($name)
|
||||
{
|
||||
$province = ProvinceModel::where('name', $name)->find();
|
||||
if (!empty($province)) {
|
||||
$list = CityModel::where('province_id', $province->id)->select();
|
||||
return $list;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user