The "~" means that you will use default values or default configuration. In your case, the behavior Timestampable, will use the default value and configuration. So you don't have to redefine them.
From the doc, here are some configuration:
Timestampable:
created:
name: created_at
type: timestamp
format: Y-m-d H:i:s
updated:
disabled: true
You will also find this "~" (a lot) in the default generator.yml
. This way, the generator, even empty, will generate a nice admin:
config:
actions: ~
fields: ~
list: ~
filter: ~
form: ~
edit: ~
new: ~
For your second question, the goal of the Timestampable
is for each modification on a row, the field updated_at
will be set with the current date. So you don't need to take care of it.
Edit:
And if you want to manually update the updated_at
field:
- first: you will have to disable the timestampable behavior for this field (see the example above
- second: you will have to do the behavior on your own.
The easiest way is to extends the preSave
function of your model and do the job here. Like:
class Article extends BaseArticle
{
public function preSave($event)
{
if(array_key_exists("your_field", $this->getModified())
{
$this->setUpdatedAt(time());
}
}
updated_at
is generally used to indicate that any field on the record was changed. Consider creating a separate field for the purpose you've described. – Stickweed