/** * new implementation for to_array * add append elements for conversion for array * @return array */ public function to_array() { $attributes = parent::to_array(); foreach ($this->appends as $attribute) { $accessor = "get_{$attribute}"; if (method_exists($this, $accessor)) { $attributes[$attribute] = $this->{$accessor}(); } } return $attributes; }