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