Skip to content

Commit 70d0f73

Browse files
Move toArray logic
1 parent 0b2c12c commit 70d0f73

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/Eloquent/DocumentModel.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,4 +754,22 @@ public function refresh()
754754

755755
return $this;
756756
}
757+
758+
/**
759+
* @inheritDoc
760+
*/
761+
public function toArray()
762+
{
763+
$embeds = [];
764+
765+
foreach (array_keys($this->getAttributes()) as $key) {
766+
if ($this->isEmbedRelation($key)) {
767+
$embeds[] = $key;
768+
}
769+
}
770+
771+
$this->loadMissing($embeds);
772+
773+
return parent::toArray();
774+
}
757775
}

src/Eloquent/EmbedsRelations.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,4 @@ public function isEmbedRelation($key)
9898
return $this->isRelation($key)
9999
&& is_a($this->{$key}(), EmbedsOneOrMany::class, true);
100100
}
101-
102-
/**
103-
* @inheritDoc
104-
*/
105-
public function toArray()
106-
{
107-
$embeds = [];
108-
109-
foreach (array_keys($this->getAttributes()) as $key) {
110-
if ($this->isEmbedRelation($key)) {
111-
$embeds[] = $key;
112-
}
113-
}
114-
115-
$this->loadMissing($embeds);
116-
117-
return parent::toArray();
118-
}
119101
}

0 commit comments

Comments
 (0)