ajaycalicut17/laravel-trash
ajaycalicut17/laravel-trash adds a simple trash bin for Laravel Eloquent models, enabling soft deletion, restoration, and permanent removal of records through a clean API, with configurable options for managing trashed data in your application.
composer require ajaycalicut17/laravel-trash and publish any package assets with php artisan vendor:publish --provider="Ajaycalicut17\LaravelTrash\LaravelTrashServiceProvider". Check the package README first for the exact service provider namespace and whether a config file or migration is shipped — v1.0.3 is still a 1.x release, so the public surface should match the README, but confirm before assuming.Illuminate\Database\Eloquent\SoftDeletes. Add the package trait/interface to the models you want to manage through the trash UI or API, then run your migrations.config/ and src/ directories after install. The config file (if present) is where route prefix, middleware, guard, and per-model registration typically live. If there is no config file, model registration is likely done via a trait or a static registry on the model itself.$post->delete()), then use the package to list trashed records and restore one ($post->restore() or the package's facade/endpoint, depending on how it exposes operations). Verify the restored record appears in your normal queries before wiring anything else.v1.0.3 itself does not introduce new features: the changelog is a set of unspecified "Fix" commits plus CI workflow updates (PHPStan, PHP-CS-Fixer, PHPMD, test runner) and a Dependabot bump for peter-evans/create-pull-request. Treat it as a patch release and pin to ^1.0.3 if you were already on 1.0.x, but read the compare diff (v1.0.2...v1.0.3) because the "Fix" PRs have no descriptions and could touch runtime behavior.
onlyTrashed()/withTrashed() through controllers, expose scoped methods or a repository per model. This keeps the trash UI, API, and scheduled cleanup reading from the same source of truth.Policy classes should still gate restore and forceDelete. Add explicit policy methods if you rely on the package's routes, since route-model binding on trashed records often needs withTrashed() binding to work at all.->chunkById(500, ...)) when driven from the package's listing, and each restore should fire model events so your observers (audit logs, search indexing) stay consistent.restoring, restored, forceDeleting, and forceDeleted events on your models to write audit entries. This is the easiest extension point and does not require touching the package internals.SerializesModels, the model is restored from the database on unserialize; confirm that trashed records resolve correctly and that a force-delete between dispatch and handle doesn't blow up the job. Prefer passing IDs and re-querying with withTrashed() explicitly.deleted_at column is the contract. If a model's table lacks deleted_at or uses a custom column name, the package will silently skip it or throw confusing query errors. Audit which models you register.QueryException and surface a clear error) before users hit it in production.->withTrashed(). If the package doesn't do this for you, you'll get 404s on restore endpoints and waste time debugging middleware.php artisan config:clear after edits in local development; stale cached config is a common cause of "my model isn't showing in the trash" reports.Model::onlyTrashed()->whereKey($id)->exists() and Model::withTrashed()->find($id). If both work but the package list is empty, the problem is almost always model registration or the package's config/guard, not the data.restored listener so package upgrades stay painless.How can I help you explore Laravel packages today?