nexusbrother/laravel-archivable
Laravel package for archiving Eloquent models instead of deleting them. Move records out of your main tables, restore them later, and query archived data with simple traits and scopes, keeping active tables lean while preserving history.
composer require nexusbrother/laravel-archivable and review the package README first. The 1.0.1 release is a patch update, so expect bug fixes only; no breaking changes are indicated by the changelog link.php artisan vendor:publish --provider="Nexusbrother\Archivable\ArchivableServiceProvider" (check the README for the exact provider/tag).Archivable trait to the Eloquent model you want to archive:
use Nexusbrother\Archivable\Traits\Archivable;
class Order extends Model
{
use Archivable;
}
$order->archive();
$activeOrders = Order::all(); // archived records excluded by default
$archivedOrders = Order::onlyArchived()->get();
withArchived() / onlyArchived() scopes rather than manually removing global scopes where possible.
Order::withArchived()->where('customer_id', $id)->get();
Order::onlyArchived()->paginate();
DB::transaction(function () use ($order) {
$order->archive();
$order->notes()->archive();
});
Order::where('created_at', '<', now()->subYears(2))
->chunkById(500, fn ($orders) => $orders->each->archive());
withArchived() intentionally and document it.update(), remember that model events may not fire, so audit hooks can be skipped.archive() explicitly in tests. Assert both default-scope behavior and explicit archived queries.Order::withoutGlobalScopes()->find($id) to confirm the record exists and is archived.email or slug can block re-use. Plan partial indexes or include the archived flag in uniqueness rules.php artisan config:clear locally and php artisan config:cache in production if your deployment uses config caching.archive() and restore() fire model events. Use observers for audit logging, but avoid infinite loops when an observer archives related models.archived_at directly.composer update nexusbrother/laravel-archivable, review the GitHub compare link for the actual commits, and run your test suite. Since this is a patch release, focus regression testing on archival/restore behavior rather than expecting new APIs.How can I help you explore Laravel packages today?