From 1be274caa68d8773680834295772e7c409ac80de Mon Sep 17 00:00:00 2001 From: Jesse O'Brien Date: Wed, 4 Jul 2012 15:46:12 -0400 Subject: [PATCH] Change update function so it uses timestamp like save Calling update() on an eloquent model has no way of overriding the timestamp that should be set if $timestamps is set on the model. This changes that so it uses the timestamp() function which is an easy way to over ride the type of timestamps used. --- laravel/database/eloquent/model.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/laravel/database/eloquent/model.php b/laravel/database/eloquent/model.php index 2ad1c72b..0f7b6a91 100644 --- a/laravel/database/eloquent/model.php +++ b/laravel/database/eloquent/model.php @@ -218,9 +218,11 @@ public static function update($id, $attributes) { $model = new static(array(), true); - if (static::$timestamps) $attributes['updated_at'] = new \DateTime; + $model->fill($attributes); - return $model->query()->where($model->key(), '=', $id)->update($attributes); + if (static::$timestamps) $model->timestamp(); + + return $model->query()->where($model->key(), '=', $id)->update($model->attributes); } /**