Fix Eloquent eager loading matching.
This commit is contained in:
@@ -38,9 +38,14 @@ class Has_One extends Has_One_Or_Many {
|
||||
{
|
||||
$foreign = $this->foreign_key();
|
||||
|
||||
foreach ($children as $key => $child)
|
||||
foreach ($parents as &$parent)
|
||||
{
|
||||
$parents[$child->$foreign]->relationships[$relationship] = $child;
|
||||
$matching = array_first($children, function($k, $v) use ($parent, $foreign)
|
||||
{
|
||||
return $v->$foreign == $parent->get_key();
|
||||
});
|
||||
|
||||
$parent->relationships[$relationship] = $matching;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user