Skip to content

2.7.0 — Trash for soft-deleting models

Choose a tag to compare

@dejwCake dejwCake released this 31 Oct 09:51
· 5 commits to main since this release

Trash for soft-deleting models: delete permanently, restore and "Show deleted". Generator output changes only for tables with a deleted_at column; nothing already generated changes.

Upgrade action

  • Update @dejwcake/craftable to 2.4.0 and dejwcake/admin-ui to 2.5.0 before regenerating (not enforced by composer.json).
  • A resource already migrated needs a new migration adding admin.{model}.restore, bulk-restore, force-delete and bulk-force-delete permissions.
  • A model generated with --without-model or written by hand needs isRestorable() (return true; is enough without parent rows).
  • Overridden controller, routes, blade-index and vue-listing templates don't get the trash; compare them with the package's.

Added

  • admin:generate:trash-controller and admin:generate:request:{force-destroy,bulk-force-destroy,restore,bulk-restore}; admin:generate runs them.
  • Model isRestorable() from its belongsTo relations; restore refuses non-restorable rows, bulk restore skips them.
  • Trash routes, permissions, "Show deleted" toggle, restore and force-delete in the Blade index and Vue listing.
  • admin:generate:request:index --template.

Changed

  • For soft-deleting models destroy runs in a transaction and bulkDestroy deletes row by row, so model events and observers fire for bulk deletes too. Integrity constraint violations come back as validation errors.
  • Long route(...) lines in the generated controller wrap at 120 characters.

Internal

  • Snapshots for a table without soft deletes guard the unchanged output; README and UPGRADE sections.