public function to_json() { // decide which fields to send over the wire if (empty($this->json_fields)) { return $this->attributes; } else { $ret = array(); foreach ($this->json_fields as $k) { $ret[$k] = $this->attributes[$k]; } return $ret; } }
public function to_json() { return parent::to_json() + array('sites' => $this->sites()->to_json()); }