/** * Map everything to an array. * * @return array */ public function toArray() { $link = []; if (!empty($this->data)) { $link['data'] = $this->data->toArray(false); } if (!empty($this->self)) { $link['self'] = $this->self; } if (!empty($this->related)) { $link['related'] = $this->related; } if (!empty($this->meta)) { $link['meta'] = $this->meta; } return $link; }
/** * Map everything to arrays. * * @return array */ public function toArray() { $document = array(); if (!empty($this->links)) { ksort($this->links); $document['links'] = $this->links; } if (!empty($this->data)) { $document['data'] = $this->data->toArray(); } if (!empty($this->included)) { $document['included'] = array(); foreach ($this->included as $resource) { $document['included'][] = $resource->toArray(); } } if (!empty($this->meta)) { $document['meta'] = $this->meta; } if (!empty($this->errors)) { $document['errors'] = $this->errors; } return $document; }