field_values as $field) { $fields[$field->name] = $field->value; } return $fields; } public function toArray($request) { $flight = parent::toArray($request); $flight['ident'] = $this->ident; // Return multiple measures so the client can pick what they want if ($this->distance instanceof Distance) { $flight['distance'] = $this->distance->units; } $flight['airline'] = new Airline($this->airline); $flight['subfleets'] = Subfleet::collection($this->subfleets); $flight['fields'] = $this->setFields(); return $flight; } }