From b4acc18b67551760bee6df9a792e86f0cebdc6b9 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 4 Sep 2015 12:22:49 +0930 Subject: [PATCH] Don't load a custom relation if the relation is already loaded --- framework/core/src/Core/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/core/src/Core/Model.php b/framework/core/src/Core/Model.php index 27315a65b..d1bdf255f 100755 --- a/framework/core/src/Core/Model.php +++ b/framework/core/src/Core/Model.php @@ -77,7 +77,7 @@ abstract class Model extends Eloquent // If a custom relation with this key has been set up, then we will load // and return results from the query and hydrate the relationship's // value on the "relationships" array. - if ($relation = $this->getCustomRelation($key)) { + if (! $this->relationLoaded($key) && ($relation = $this->getCustomRelation($key))) { if (! $relation instanceof Relation) { throw new LogicException('Relationship method must return an object of type ' . 'Illuminate\Database\Eloquent\Relations\Relation');