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.
This commit is contained in:
Jesse O'Brien 2012-07-04 15:46:12 -04:00
parent 3ba5c00e5f
commit 1be274caa6
1 changed files with 4 additions and 2 deletions

View File

@ -218,9 +218,11 @@ public static function update($id, $attributes)
{ {
$model = new static(array(), true); $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);
} }
/** /**