软删除的删除字段默认值更改为null 兼容更多的时间字段类型

This commit is contained in:
thinkphp
2016-08-20 14:05:19 +08:00
parent 684ed543a6
commit a30b5d7f01

View File

@@ -104,7 +104,9 @@ trait SoftDelete
{
if (static::$deleteTime) {
// 恢复删除
$this->setAttr(static::$deleteTime, 0);
$name = static::$deleteTime;
$this->change[] = $name;
$this->data[$name] = ['exp', 'null'];
return $this->isUpdate()->save();
}
return false;
@@ -118,7 +120,7 @@ trait SoftDelete
protected static function base($query)
{
if (static::$deleteTime) {
$query->where(static::$deleteTime, 0);
$query->where(static::$deleteTime, 'exp', 'null');
}
}