From c4ece2d51f6a0c680388ea826935b6b5b386ba65 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 16 Aug 2011 23:04:25 -0500 Subject: [PATCH] rearrange __get hierarchy so eloquent models can have methods that have the same name as columns. --- system/db/eloquent/model.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system/db/eloquent/model.php b/system/db/eloquent/model.php index 707f57b1..ca0ea554 100644 --- a/system/db/eloquent/model.php +++ b/system/db/eloquent/model.php @@ -424,9 +424,13 @@ public function delete($id = null) */ public function __get($key) { + if (array_key_exists($key, $this->attributes)) + { + return $this->attributes[$key]; + } // Is the requested item a model relationship that has already been loaded? // All of the loaded relationships are stored in the "ignore" array. - if (array_key_exists($key, $this->ignore)) + elseif (array_key_exists($key, $this->ignore)) { return $this->ignore[$key]; } @@ -438,10 +442,6 @@ public function __get($key) return $this->ignore[$key] = (in_array($this->relating, array('has_one', 'belongs_to'))) ? $query->first() : $query->get(); } - elseif (array_key_exists($key, $this->attributes)) - { - return $this->attributes[$key]; - } } /**