In my database my date columns aren’t named “created_at” and “updated_at” but instead “dateCreated” and “dateUpdated”. Right now for every ActiveRecord I create I’m modifying this in the behaviors() function like this:
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'value' => new Expression('NOW()'),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['dateCreated', 'dateUpdated'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['dateUpdated'],
ActiveRecord::EVENT_BEFORE_DELETE => ['dateDeleted'],
],
],
];
}
Is there any way I can change this globally for the ActiveRecords so I don’t have to add this piece of code for all my models?