Commit 8d17702b authored by Taylor Otwell's avatar Taylor Otwell

Merge branch 'staging' into develop

parents 2d4fa721 14e9488c
......@@ -325,14 +325,21 @@ class Has_Many_And_Belongs_To extends Relationship {
{
$foreign = $this->foreign_key();
foreach ($parents as &$parent)
$dictionary = array();
foreach ($children as $child)
{
$matching = array_filter($children, function($v) use (&$parent, $foreign)
$dictionary[$child->pivot->$foreign][] = $child;
}
foreach ($parents as &$parent)
{
return $v->pivot->$foreign == $parent->get_key();
});
$parent_key = $parent->get_key();
$parent->relationships[$relationship] = array_values($matching);
if (isset($dictionary[$parent_key]))
{
$parent->relationships[$relationship] = $dictionary[$parent_key];
}
}
}
......
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