From f6c7cf2dcd08e1fbe26c4995dd87bd966201605f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vini=CC=81cius=20Fragoso?= Date: Sun, 7 Oct 2012 12:15:57 -0300 Subject: [PATCH] Fixing pivot on has_one aswell as properly indenting --- laravel/database/eloquent/relationships/has_one.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/relationships/has_one.php b/laravel/database/eloquent/relationships/has_one.php index fa4d12f8..cd8a84ca 100644 --- a/laravel/database/eloquent/relationships/has_one.php +++ b/laravel/database/eloquent/relationships/has_one.php @@ -41,18 +41,20 @@ class Has_One extends Has_One_Or_Many { $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()]; + } } }