软删除restore方法支持传入条件

This commit is contained in:
thinkphp
2016-09-13 22:02:26 +08:00
parent 9c227e9e8e
commit 3e79ff0c28

View File

@@ -101,16 +101,15 @@ trait SoftDelete
/** /**
* 恢复被软删除的记录 * 恢复被软删除的记录
* @access public * @access public
* @param array $where 更新条件
* @return integer * @return integer
*/ */
public function restore() public function restore($where = [])
{ {
if (static::$deleteTime) { if (static::$deleteTime) {
// 恢复删除 // 恢复删除
$name = static::$deleteTime; $name = static::$deleteTime;
$this->change[] = $name; return $this->isUpdate()->save([$name => null], $where);
$this->data[$name] = null;
return $this->isUpdate()->save();
} }
return false; return false;
} }
@@ -118,6 +117,7 @@ trait SoftDelete
/** /**
* 查询默认不包含软删除数据 * 查询默认不包含软删除数据
* @access protected * @access protected
* @param \think\db\Query $query 查询对象
* @return void * @return void
*/ */
protected static function base($query) protected static function base($query)