Commit 1df8fa91 by Taylor Otwell

Merge pull request #1322 from vFragosop/eloquent/relationship_performance

Fixing has_one iterations
parents 790a5406 f6c7cf2d
...@@ -41,18 +41,20 @@ class Has_One extends Has_One_Or_Many { ...@@ -41,18 +41,20 @@ class Has_One extends Has_One_Or_Many {
$children_hash = array(); $children_hash = array();
foreach ($children as $child) foreach ($children as $child)
{ {
if (array_key_exists($child->pivot->$foreign, $children_hash)) if (array_key_exists($child->$foreign, $children_hash))
{ {
continue; continue;
} }
$children_hash[$child->pivot->$foreign] = $child; $children_hash[$child->$foreign] = $child;
} }
foreach ($parents as $parent) foreach ($parents as $parent)
{ {
if (array_key_exists($parent->get_key(), $children_hash)) if (array_key_exists($parent->get_key(), $children_hash))
{
$parent->relationships[$relationship] = $children_hash[$parent->get_key()]; $parent->relationships[$relationship] = $children_hash[$parent->get_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