mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
修正软删除
This commit is contained in:
@@ -30,7 +30,7 @@ trait SoftDelete
|
|||||||
{
|
{
|
||||||
$model = new static();
|
$model = new static();
|
||||||
$field = $model->getDeleteTimeField(true);
|
$field = $model->getDeleteTimeField(true);
|
||||||
return $model->db(false);
|
return $model->getQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +42,7 @@ trait SoftDelete
|
|||||||
{
|
{
|
||||||
$model = new static();
|
$model = new static();
|
||||||
$field = $model->getDeleteTimeField(true);
|
$field = $model->getDeleteTimeField(true);
|
||||||
return $model->db(false)
|
return $model->getQuery()
|
||||||
->useSoftDelete($field, ['not null', '']);
|
->useSoftDelete($field, ['not null', '']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ trait SoftDelete
|
|||||||
$this->data[$name] = $this->autoWriteTimestamp($name);
|
$this->data[$name] = $this->autoWriteTimestamp($name);
|
||||||
$result = $this->isUpdate()->save();
|
$result = $this->isUpdate()->save();
|
||||||
} else {
|
} else {
|
||||||
$result = $this->db(false)->delete($this->data);
|
$result = $this->getQuery()->delete($this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->trigger('after_delete', $this);
|
$this->trigger('after_delete', $this);
|
||||||
@@ -117,7 +117,7 @@ trait SoftDelete
|
|||||||
$where[$pk] = $this->getData($pk);
|
$where[$pk] = $this->getData($pk);
|
||||||
}
|
}
|
||||||
// 恢复删除
|
// 恢复删除
|
||||||
return $this->db(false)
|
return $this->getQuery()
|
||||||
->useSoftDelete($name, ['not null', ''])
|
->useSoftDelete($name, ['not null', ''])
|
||||||
->where($where)
|
->where($where)
|
||||||
->update([$name => null]);
|
->update([$name => null]);
|
||||||
|
|||||||
Reference in New Issue
Block a user