| 
														
															@@ -325,14 +325,21 @@ class Has_Many_And_Belongs_To extends Relationship { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	{ 
														 | 
														
														 | 
														
															 	{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		$foreign = $this->foreign_key(); 
														 | 
														
														 | 
														
															 		$foreign = $this->foreign_key(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		$dictionary = array(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		foreach ($children as $child) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			$dictionary[$child->pivot->$foreign][] = $child; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+		} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		foreach ($parents as &$parent) 
														 | 
														
														 | 
														
															 		foreach ($parents as &$parent) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		{ 
														 | 
														
														 | 
														
															 		{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			$matching = array_filter($children, function($v) use (&$parent, $foreign) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-			{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-				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]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+			} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 		} 
														 | 
														
														 | 
														
															 		} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 	} 
														 | 
														
														 | 
														
															 	} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 |