Browse Source

Merge pull request #823 from Vespakoen/patch-3

ATTENTION! Fixing reference issue in relationship matching (Causing MAMP, and other installs, to crash when eager-loading)
Taylor Otwell 12 years ago
parent
commit
527977337d

+ 1 - 1
laravel/database/eloquent/relationships/belongs_to.php

@@ -89,7 +89,7 @@ class Belongs_To extends Relationship {
 
 		foreach ($children as &$child)
 		{
-			$parent = array_first($parents, function($k, $v) use ($child, $foreign)
+			$parent = array_first($parents, function($k, $v) use (&$child, $foreign)
 			{
 				return $v->get_key() == $child->$foreign;
 			});

+ 1 - 1
laravel/database/eloquent/relationships/has_many.php

@@ -93,7 +93,7 @@ class Has_Many extends Has_One_Or_Many {
 
 		foreach ($parents as &$parent)
 		{
-			$matching = array_filter($children, function($v) use ($parent, $foreign)
+			$matching = array_filter($children, function($v) use (&$parent, $foreign)
 			{
 				return $v->$foreign == $parent->get_key();
 			});

+ 1 - 1
laravel/database/eloquent/relationships/has_many_and_belongs_to.php

@@ -327,7 +327,7 @@ class Has_Many_And_Belongs_To extends Relationship {
 
 		foreach ($parents as &$parent)
 		{
-			$matching = array_filter($children, function($v) use ($parent, $foreign)
+			$matching = array_filter($children, function($v) use (&$parent, $foreign)
 			{
 				return $v->pivot->$foreign == $parent->get_key();
 			});

+ 1 - 1
laravel/database/eloquent/relationships/has_one.php

@@ -40,7 +40,7 @@ class Has_One extends Has_One_Or_Many {
 
 		foreach ($parents as &$parent)
 		{
-			$matching = array_first($children, function($k, $v) use ($parent, $foreign)
+			$matching = array_first($children, function($k, $v) use (&$parent, $foreign)
 			{
 				return $v->$foreign == $parent->get_key();
 			});