Merge pull request #1322 from vFragosop/eloquent/relationship_performance
Fixing has_one iterations
This commit is contained in:
commit
1df8fa91fc
|
@ -41,18 +41,20 @@ public function match($relationship, &$parents, $children)
|
|||
$children_hash = array();
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if (array_key_exists($child->pivot->$foreign, $children_hash))
|
||||
if (array_key_exists($child->$foreign, $children_hash))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$children_hash[$child->pivot->$foreign] = $child;
|
||||
$children_hash[$child->$foreign] = $child;
|
||||
}
|
||||
|
||||
foreach ($parents as $parent)
|
||||
{
|
||||
if (array_key_exists($parent->get_key(), $children_hash))
|
||||
{
|
||||
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue