Skip to main content

What Are Soft Deletes?

Instead of removing a row from the database, a soft delete stamps a deleted_at timestamp on it. The row stays in the database but is hidden from normal queries. This lets you:
  • Recover accidentally deleted records
  • Keep audit history
  • Show users a “trash” bin

1. Enable Soft Deletes

Already know your schema? Run npx ilana make:model Post --migration to scaffold both files at once, add the deleted_at column, then skip straight to Enable on the model.
Add deleted_at to your migration:
Enable on the model:

2. Custom Column Name

If your column is named differently, configure it:

3. Deleting

Bulk soft-delete:

4. Normal Queries Exclude Deleted Records

This applies to every query automatically — get(), find(), count(), exists(), paginate() — all exclude soft-deleted rows.

5. Including Deleted Records

6. Check if a Record is Deleted

7. Restore a Deleted Record

8. Permanently Delete

9. Building a Trash API

A complete trash/restore/purge flow:

10. Relations Across Soft Deletes

By default, eager-loaded relations also exclude soft-deleted records. To include trashed related records:

Quick Reference