beforeValidationOnCreate and beforeValidationOnUpdate — those functions I need.
But what about initialize()? How I can do some operations with Model fields after creating a new instance? For example:
class MyModel extends Model
{
public $uuid;
public function initialize()
{
$this->uuid = \MyNameSpace\MyGenerator::generateUUID();
}
}
$myModel = new \MyModel();
echo $myModel->uuid; // uuid may be not set sometimes
In Models we can't override __construct(), because it is "final" :-(