In my model I have:
public function beforeCreate()
{
$this->created = date("Y:m:d H:i:s");
$this->modified = date("Y:m:d H:i:s");
}
public function beforeUpdate()
{
$this->modified = date("Y:m:d H:i:s");
}
In the database both columns are not null.
In the controller the record is either created or updated using save().
For existing records beforeUpdate() works and updates an existing date.
When creating a new record I get the following error messages on executing beforeCreate():
created is required
modified is required
Does this mean that I must always 'initialize' flelds created and modified before the record is created in the database?
I think so.
https://docs.phalcon.io/en/latest/reference/models.html#events-and-events-manager