Skip to content

Commit

Permalink
New property relations eager loading fix (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriy-invoiced committed Sep 10, 2021
1 parent 4ba83be commit b84cfd0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Hydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public static function hydrate(array $result, $modelClass, array $eagerLoaded):

foreach ($ids[$k] as $j => $id) {
if (isset($relationships[$id])) {
$models[$j]->setRelation($k, $relationships[$id]);
if ($property->isPersisted()) {
$models[$j]->setRelation($k, $relationships[$id]);
// older style properties do not support this type of hydration
if (!$property->isPersisted()) {
} else {
$models[$j]->hydrateValue($k, $relationships[$id]);
}
}
Expand All @@ -66,9 +67,10 @@ public static function hydrate(array $result, $modelClass, array $eagerLoaded):

foreach ($ids[$k] as $j => $id) {
if (isset($relationships[$id])) {
$models[$j]->setRelation($k, $relationships[$id]);
if ($property->isPersisted()) {
$models[$j]->setRelation($k, $relationships[$id]);
// older style properties do not support this type of hydration
if (!$property->isPersisted()) {
} else {
$models[$j]->hydrateValue($k, $relationships[$id]);
}
} else {
Expand Down

0 comments on commit b84cfd0

Please sign in to comment.