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; } }