修复模型时间字段无法更新问题

This commit is contained in:
2017-08-26 18:10:19 +08:00
parent 356cccd1d4
commit 9deab68359

View File

@@ -116,7 +116,7 @@ class BaseModel {
* @return $this
*/
public function setAttr($name, $value, $data = []) {
if (is_null($value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) {
if ((is_null($value) || !$value) && $this->autoWriteTimestamp && in_array($name, [$this->createTime, $this->updateTime])) {
// 自动写入的时间戳字段
$value = $this->autoWriteTimestamp($name);
} else {