ayoub-amzil / soft-delete-logger
Log soft deletes and restore actions on Eloquent models with user tracking in Laravel.
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ayoub-amzil/soft-delete-logger
Requires
- php: ^8.1
- illuminate/database: ^12.0
- illuminate/support: ^12.0
This package is auto-updated.
Last update: 2025-11-26 17:55:54 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