- What is yocto/illuminate-database-softdeletes used for?
- It adds boolean soft delete support to Illuminate Database, the database component used by Laravel. The package provides a trait and query scopes so you can mark records as deleted, exclude trashed rows, restore records, and force delete them permanently. It is intended for projects that use Illuminate Database outside a full Laravel application.
- How do I install yocto/illuminate-database-softdeletes with Composer?
- Install it with Composer using the package name yocto/illuminate-database-softdeletes. Run the Composer require command in the project where Illuminate Database is already set up. After installation, add the package's trait to the models that need soft delete behavior.
- Does this package work outside a full Laravel application?
- Yes. The package is specifically described as adding soft delete support to Illuminate Database outside a full Laravel app. You can use its trait and query scopes in a standalone project that depends on Illuminate Database. You do not need the full Laravel framework for these soft delete features.
- How do I configure a model for boolean soft deletes?
- Add the package's soft delete trait to your model and ensure its table has a boolean column for the deletion flag. The trait and query scopes then handle marking records deleted, excluding them from queries, restoring them, and force deleting them. Check the package README for the exact trait name and column configuration expected.
- How do I exclude trashed records from queries?
- Use the package's query scopes to exclude rows whose boolean delete flag is set. This keeps normal queries limited to active records. Review the package documentation for the exact scope names and how to apply them to your query builder or model queries.
- How do I restore a soft-deleted record?
- The package provides restore support for records marked deleted with the boolean flag. Load the soft-deleted record and use the package's restore method or scope to clear the deletion flag. The record should then appear in normal queries again.
- How do I permanently delete a soft-deleted record?
- Use the package's force delete functionality to remove a record permanently from the database. This bypasses soft deletion and cannot be undone with the package's restore feature. Reserve force deletes for cases where permanent removal is intended.
- Is the package compatible with my Laravel or Illuminate Database version?
- Compatibility depends on the Illuminate Database version required by the package and the version your project uses. Check the package's Composer constraints before installing or upgrading Laravel or Illuminate components. The context does not specify supported versions, so verify against the package metadata.
- How can I test soft delete, restore, and force delete behavior?
- Write tests that create a record, soft delete it, confirm it is excluded from normal queries, restore it, and confirm it appears again. Also test force delete to ensure the row is permanently removed. Run these tests against the same database engine and schema you use in production where possible.
- What should I check before using this package in production?
- Confirm the boolean deletion column, indexes, and model trait configuration match the package's expectations. Ensure every query path uses the appropriate scopes so trashed rows are not exposed accidentally. Check the package's maintenance status and Composer constraints, and test restore and force delete paths before production. If you use full Laravel, compare it with Laravel's built-in SoftDeletes trait.