Commit c751844a authored by Taylor Otwell's avatar Taylor Otwell

fixed belongs_to eager loading bug when parent does not exist.

parent 8f8c5f6d
...@@ -200,10 +200,13 @@ class Hydrator { ...@@ -200,10 +200,13 @@ class Hydrator {
// Match the child models with their parent by ID. // Match the child models with their parent by ID.
// ----------------------------------------------------- // -----------------------------------------------------
foreach ($parents as &$parent) foreach ($parents as &$parent)
{
if (array_key_exists($parent->$relating_key, $children))
{ {
$parent->ignore[$include] = $children[$parent->$relating_key]; $parent->ignore[$include] = $children[$parent->$relating_key];
} }
} }
}
/** /**
* Eagerly load a many-to-many relationship. * Eagerly load a many-to-many relationship.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment