Browse Source

added laravel like touch() method to AutoTimestamp

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
01d0323521
  1. 14
      framework/yii/behaviors/AutoTimestamp.php

14
framework/yii/behaviors/AutoTimestamp.php

@ -99,4 +99,18 @@ class AutoTimestamp extends Behavior
return time(); return time();
} }
} }
/**
* Updates a timestamp attribute to the current timestamp.
*
* ```php
* $model->touch('lastVisit');
* ```
* @param string $attribute the name of the attribute to update.
*/
public function touch($attribute)
{
$timestamp = $this->evaluateTimestamp();
$this->owner->updateAttributes([$attribute => $timestamp]);
}
} }

Loading…
Cancel
Save