trait SoftDeleteTrait

Trait SoftDeleteTrait to be used in Models, requires deleted_at column in database table

Assumes presence of these members

Properties

Controller read-only $mod
array read-only $properties
string read-only $table_name

Provides the methods:

Methods

_scopeNotDeleted(Query $query)

No description

_scopeSoftDeleted(Query $query)

Function is triggered on scopeSoftDeleted()

bool
canForceDelete()

Makes sure the soft delete minimum keep duration is observed.

bool
forceDelete($force = false)

Will execute standard model delete method.

int
getSoftDeleteKeepDays()

Returns how many days the soft deleted documents are kept.

void
initSoftDeleteTrait()

No description

bool
isSoftDeleted()

No description

onForceDelete()

No description

onRestore()

Implement to process event

onSoftDelete()

Implement to process event

bool
restore()

Recover soft deleted item

scopeNotDeleted()

Default active scope.

scopeSoftDeleted()

Scope to return only soft deleted records.

int|bool|null
softDelete()

Mark this model as deleted by setting deleted_at to current time

withDeleted()

No description

Details

at line 37
Query _scopeNotDeleted(Query $query)

No description

Parameters

Query $query

Return Value

Query

at line 51
Query _scopeSoftDeleted(Query $query)

Function is triggered on scopeSoftDeleted()

Parameters

Query $query

Return Value

Query

at line 150
bool canForceDelete()

Makes sure the soft delete minimum keep duration is observed.

e.g. document was deleted 30 days ago, but the keep duration was increased to 120 days.

Return Value

bool

at line 86
bool forceDelete($force = false)

Will execute standard model delete method.

Parameters

$force

Return Value

bool

at line 139
int getSoftDeleteKeepDays()

Returns how many days the soft deleted documents are kept.

Return Value

int

at line 33
void initSoftDeleteTrait()

No description

Return Value

void

at line 122
bool isSoftDeleted()

No description

Return Value

bool

at line 169
onForceDelete()

No description

at line 167
onRestore()

Implement to process event

at line 162
onSoftDelete()

Implement to process event

at line 106
bool restore()

Recover soft deleted item

Return Value

bool

Was restore successful?

Exceptions

AuditException

at line 31
ModelCollection scopeNotDeleted()

Default active scope.

Return Value

ModelCollection

at line 31
ModelCollection scopeSoftDeleted()

Scope to return only soft deleted records.

Return Value

ModelCollection

at line 67
int|bool|null softDelete()

Mark this model as deleted by setting deleted_at to current time

Return Value

int|bool|null

at line 59
ModelCollection withDeleted()

No description

Return Value

ModelCollection