From 258169ea0000a8b90f5d56b7102c2212e0bad612 Mon Sep 17 00:00:00 2001 From: RK Date: Mon, 24 Sep 2012 09:58:20 -0400 Subject: [PATCH] [#1261] get_key now pulls from $original instead This is in reference to issue #1261, where Model->get_key() returns the key from the $attributes instead of from the $original property. This breaks the functionality of a model with a primary key that may change, as the SQL generated will be something like: UPDATE `model` SET `key` = 'new-key' WHERE `key` = 'new-key'; Which won't update the model in the database. --- laravel/database/eloquent/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index c2566496..c57b36ad 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -544,7 +544,7 @@ public function get_dirty() */ public function get_key() { - return $this->get_attribute(static::$key); + return get_array($this->original, static::$key); } /** @@ -721,7 +721,7 @@ public function __isset($key) { if (array_key_exists($key, $this->$source)) return true; } - + if (method_exists($this, $key)) return true; }