'city:json_string', 'State' => 'state:json_string', 'Country' => 'country:json_string', 'Lat' => 'lat:json_float', 'Lng' => 'lng:json_float', 'RegionId' => 'region_id:json_int', ]; /** * @param null $expand * @param array $fields * @param array $relations * @param array $params * @return array */ public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array()) { $location = $this->object; if(!$location instanceof DataCenterLocation) return []; if(!count($relations)) $relations = $this->getAllowedRelations(); $values = parent::serialize($expand, $fields, $relations, $params); if (!empty($expand)) { $exp_expand = explode(',', $expand); foreach ($exp_expand as $relation) { switch (trim($relation)) { case 'region': unset($values['region_id']); $values['region'] = SerializerRegistry ::getInstance() ->getSerializer($location->getRegion()) ->serialize($expand); break; } } } return $values; } }