Skip to content

Commit

Permalink
fix create timestamp issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Nov 25, 2021
1 parent 88c9c99 commit 7e52ef5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
In order to read more about upgrading and BC breaks have a look at the [UPGRADE Document](UPGRADE.md).

## 4.0.2 (25. November 2021)

+ Fix issue when `timestamp_create` is provided by admin UI the value is is not accpeted as its overwritten by the TimestampBehavior.

## 4.0.1 (3. August 2021)

+ [#25](https://github.com/luyadev/luya-module-news/pull/25) Fixed issue when using the Article Model in Queue Context.
Expand Down
13 changes: 12 additions & 1 deletion src/models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,23 @@ public function behaviors()
],
[
'class' => TimestampBehavior::class,
'createdAtAttribute' => 'timestamp_create',
'createdAtAttribute' => false,
'updatedAtAttribute' => 'timestamp_update'
]
];
}

public function init()
{
parent::init();

$this->on(self::EVENT_BEFORE_INSERT, function() {
if (empty($this->timestamp_create)) {
$this->timestamp_create = time();
}
});
}

/**
* @inheritdoc
*/
Expand Down

0 comments on commit 7e52ef5

Please sign in to comment.