Commit 01d03235 by Carsten Brandt

added laravel like touch() method to AutoTimestamp

parent 34dc150f
...@@ -99,4 +99,18 @@ class AutoTimestamp extends Behavior ...@@ -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]);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment