ayoub-amzil / soft-delete-logger
Log soft deletes and restore actions on Eloquent models with user tracking in Laravel.
1.1.0
2025-07-27 01:05 UTC
Requires
- php: ^8.1
- illuminate/database: ^12.0
- illuminate/support: ^12.0
This package is auto-updated.
Last update: 2026-02-26 18:33:31 UTC
README
Log every soft delete and restore action on your Eloquent models β including the authenticated user who performed it.
π¦ Installation
composer require ayoub-amzil/soft-delete-logger
π οΈ Setup
1. Publish the migration
php artisan vendor:publish --tag=soft-delete-logger-migrations
Then migrate:
php artisan migrate
2. Add the trait to your model
use AyoubAmzil\SoftDeleteLogger\Traits\LogsSoftDeletes; class Product extends Model { use SoftDeletes, LogsSoftDeletes; }
Thatβs it!
π What it logs
Whenever a model is soft-deleted or restored, it logs:
model: Class name of the modelmodel_id: The ID of the deleted/restored recorduser_id: The ID of the currently authenticated user (ornullif not logged in)action: Eithersoft_deletedorrestoredtimestamps: When the action happened
π Log Table Example
| id | model | model_id | user_id | action | created_at |
|---|---|---|---|---|---|
| 1 | App\Models\Post | 42 | 1 | soft_deleted | ... |
| 2 | App\Models\Post | 42 | 1 | restored | ... |
β Compatibility
- Laravel 10+
- Works with any model using
SoftDeletes