12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\admin\model\system;
- use crmeb\traits\ModelTrait;
- use crmeb\basic\BaseModel;
- class SystemCity extends BaseModel
- {
-
- protected $pk = 'id';
-
- protected $name = 'system_city';
- use ModelTrait;
-
- public function children()
- {
- return $this->hasMany(self::class, 'parent_id','city_id')->order('id DESC');
- }
- public static function getList($where = [])
- {
- $list = self::withAttr('parent_id', function($value, $data) {
- if($value == 0){
- return '中国';
- }else{
- return self::where('city_id',$value)->value('name');
- }
- })->where('parent_id', $where['parent_id'])->select()->toArray();
- return $list;
- }
- }
|