\traits\modelSoftDelete

Summary

Methods
Properties
Constants
trashed()
withTrashed()
onlyTrashed()
delete()
destroy()
restore()
No public properties found
No constants found
base()
getDeleteTimeField()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

trashed()

trashed() : bool

判断当前实例是否被软删除

Returns

bool —

withTrashed()

withTrashed() : \think\db\Query

查询包含软删除的数据

Returns

\think\db\Query —

onlyTrashed()

onlyTrashed() : \think\db\Query

只查询软删除数据

Returns

\think\db\Query —

delete()

delete(bool  $force = false) : int

删除当前的记录

Parameters

bool $force

是否强制删除

Returns

int —

destroy()

destroy(mixed  $data, bool  $force = false) : int

删除记录

Parameters

mixed $data

主键列表(支持闭包查询条件)

bool $force

是否强制删除

Returns

int —

成功删除的记录数

restore()

restore(array  $where = []) : int

恢复被软删除的记录

Parameters

array $where

更新条件

Returns

int —

base()

base(\think\db\Query  $query) : \think\db\Query

查询默认不包含软删除数据

Parameters

\think\db\Query $query

查询对象

Returns

\think\db\Query —

getDeleteTimeField()

getDeleteTimeField(bool  $read = false) : string

获取软删除字段

Parameters

bool $read

是否查询操作(写操作的时候会自动去掉表别名)

Returns

string —