October\Rain\Database\Traits\SoftDelete
Overview
SoftDelete trait for flagging models as deleted instead of actually deleting them.
Protected Properties
protected bool $forceDeleting
forceDeleting indicates if the model is currently force deleting.
Public Methods
public static bootSoftDelete()
public static bootSoftDelete(): void
bootSoftDelete trait for a model.
public forceDelete()
public forceDelete(): void
forceDelete on a soft deleted model.
public getDeletedAtColumn()
public getDeletedAtColumn(): string
getDeletedAtColumn gets the name of the "deleted at" column.
public getQualifiedDeletedAtColumn()
public getQualifiedDeletedAtColumn(): string
getQualifiedDeletedAtColumn gets the fully qualified "deleted at" column.
public isSoftDelete()
public isSoftDelete(): bool
isSoftDelete helper method to check if the model is currently being hard or soft deleted, useful in events.
public isSoftDeleteEnabled()
public isSoftDeleteEnabled(): bool
isSoftDeleteEnabled allows for programmatic toggling
public static onlyTrashed()
public static onlyTrashed(): Illuminate\Database\Eloquent\Builder|static
onlyTrashed gets a new query builder that only includes soft deletes.
public restore()
public restore(): bool|null
restore a soft-deleted model instance.
public static restored()
public static restored(Closure|string $callback): void
restored registers a restored model event with the dispatcher.
public static restoring()
public static restoring(Closure|string $callback): void
restoring registers a restoring model event with the dispatcher.
public static softDeleted()
public static softDeleted(Closure|string $callback): void
softDeleted registers a "trashed" model event callback with the dispatcher.
public trashed()
public trashed(): bool
trashed determines if the model instance has been soft-deleted.
public static withTrashed()
public static withTrashed(): Illuminate\Database\Eloquent\Builder|static
withTrashed gets a new query builder that includes soft deletes.
Protected Methods
protected performDeleteOnModel()
protected performDeleteOnModel(): void
performDeleteOnModel performs the actual delete query on this model instance.
protected performRestoreOnRelations()
protected performRestoreOnRelations(): void
performRestoreOnRelations locates relations with softDelete flag and cascades the restore event.
protected performSoftDeleteOnRelations()
protected performSoftDeleteOnRelations(): void
performSoftDeleteOnRelations locates relations with softDelete flag and cascades the delete event.
protected runSoftDelete()
protected runSoftDelete(): void
runSoftDelete performs the actual delete query on this model instance.