hi all…
in yii2.
TimestampBehavior, if we create new record, it automatically fill to update time too. in reality, if we just create new record then the date should go to crate datetime only and not to update time. we do not want our article listed as recent update time when we never do update to that article. so, i purpose a new change to TimestampBehavior.php line 90 as follow:
if (empty($this->attributes)) {
$this->attributes = [
- BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute, $this->updatedAtAttribute],
+ BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute],
BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedAtAttribute,
];
}
BlameableBehavior, same with TimestampBehavior, if we just create a article then our name must just registered as author in create by only, not to update by.
if (empty($this->attributes)) {
$this->attributes = [
- BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute],
+ BaseActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute],
BaseActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute,
];
}
thank you for all developers to this amazing framework