increment version. refactor eloquent eager loading matching.
This commit is contained in:
@@ -87,17 +87,18 @@ class Belongs_To extends Relationship {
|
||||
{
|
||||
$foreign = $this->foreign_key();
|
||||
|
||||
$parents_hash = array();
|
||||
$dictionary = array();
|
||||
|
||||
foreach ($parents as $parent)
|
||||
{
|
||||
$parents_hash[$parent->get_key()] = $parent;
|
||||
$dictionary[$parent->get_key()] = $parent;
|
||||
}
|
||||
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if (array_key_exists($child->$foreign, $parents_hash))
|
||||
if (array_key_exists($child->$foreign, $dictionary))
|
||||
{
|
||||
$child->relationships[$relationship] = $parents_hash[$child->$foreign];
|
||||
$child->relationships[$relationship] = $dictionary[$child->$foreign];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,17 +91,18 @@ class Has_Many extends Has_One_Or_Many {
|
||||
{
|
||||
$foreign = $this->foreign_key();
|
||||
|
||||
$children_hash = array();
|
||||
$dictionary = array();
|
||||
|
||||
foreach ($children as $child)
|
||||
{
|
||||
$children_hash[$child->$foreign][] = $child;
|
||||
$dictionary[$child->$foreign][] = $child;
|
||||
}
|
||||
|
||||
foreach ($parents as $parent)
|
||||
{
|
||||
if (array_key_exists($parent->get_key(), $children_hash))
|
||||
if (array_key_exists($key = $parent->get_key(), $dictionary))
|
||||
{
|
||||
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
|
||||
$parent->relationships[$relationship] = $dictionary[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,17 +328,18 @@ class Has_Many_And_Belongs_To extends Relationship {
|
||||
{
|
||||
$foreign = $this->foreign_key();
|
||||
|
||||
$children_hash = array();
|
||||
$dictionary = array();
|
||||
|
||||
foreach ($children as $child)
|
||||
{
|
||||
$children_hash[$child->pivot->$foreign][] = $child;
|
||||
$dictionary[$child->pivot->$foreign][] = $child;
|
||||
}
|
||||
|
||||
foreach ($parents as $parent)
|
||||
{
|
||||
if (array_key_exists($parent->get_key(), $children_hash))
|
||||
if (array_key_exists($key = $parent->get_key(), $dictionary))
|
||||
{
|
||||
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
|
||||
$parent->relationships[$relationship] = $dictionary[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,22 +38,18 @@ class Has_One extends Has_One_Or_Many {
|
||||
{
|
||||
$foreign = $this->foreign_key();
|
||||
|
||||
$children_hash = array();
|
||||
$dictionary = array();
|
||||
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if (array_key_exists($child->$foreign, $children_hash))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$children_hash[$child->$foreign] = $child;
|
||||
$dictionary[$child->$foreign] = $child;
|
||||
}
|
||||
|
||||
foreach ($parents as $parent)
|
||||
{
|
||||
if (array_key_exists($parent->get_key(), $children_hash))
|
||||
if (array_key_exists($key = $parent->get_key(), $dictionary))
|
||||
{
|
||||
$parent->relationships[$relationship] = $children_hash[$parent->get_key()];
|
||||
$parent->relationships[$relationship] = $dictionary[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user