/** * Serialize intance's relations. * * @param \Illuminate\Support\Contracts\ArrayableInterface $instance * @return array */ public function serializeRelations(ArrayableInterface $instance) { $links = array(); $side_loads = $instance->getSideLoads(); foreach ($side_loads as $load) { $relation = $instance->{$load}; $instance->__unset($load); if ($this->isEmptyOrNull($relation)) { continue; } if (array_key_exists($load, $this->url_overrides)) { $links[$load] = $this->buildLink($relation, $this->url_overrides[$load]); } else { $links[$load] = $this->buildLink($relation); } } if (count($links)) { $instance->setAttribute('links', $links); } return $instance; }
protected function mergeErrors(ArrayableInterface $errors) { foreach ($errors->toArray() as $error) { $this->addError($error); } }
/** * Morph a value to an array. * * @param array|\Illuminate\Support\Contracts\ArrayableInterface $value * @return array */ protected function morphToArray($value) { return $value instanceof ArrayableInterface ? $value->toArray() : $value; }