From e1ef10a414edbef92cc9cf7f21633b435a46cc70 Mon Sep 17 00:00:00 2001 From: Richard Neal Date: Tue, 4 Jan 2022 04:04:31 -0800 Subject: [PATCH] Attributable::relationsToArray() doesn't return entity attributes --- src/Traits/Attributable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Traits/Attributable.php b/src/Traits/Attributable.php index ca15a33..76179f9 100644 --- a/src/Traits/Attributable.php +++ b/src/Traits/Attributable.php @@ -118,10 +118,10 @@ public function relationsToArray() $relations = array_keys($this->getEntityAttributeRelations()); foreach ($relations as $relation) { - if (array_key_exists($relation, $attributes)) { - $eavAttributes[$relation] = $this->getAttribute($relation) instanceof BaseCollection - ? $this->getAttribute($relation)->toArray() : $this->getAttribute($relation); + $eavAttributes[$relation] = $this->getAttribute($relation) instanceof BaseCollection + ? $this->getAttribute($relation)->toArray() : $this->getAttribute($relation); + if (array_key_exists($relation, $attributes)) { // By unsetting the relation from the attributes array we will make // sure we do not provide a duplicity when adding the namespace. // Otherwise it would keep the relation as a key in the root.