venturecraft/revisionable
Revisionable adds automatic revision history to your Laravel Eloquent models. Track who changed what and when, store diffs for selected attributes, and browse or restore past versions. Useful for auditing, activity logs, and rollback of record changes.
Begin by installing the package via Composer (composer require venturecraft/revisionable) and publishing its config/migrations (php artisan vendor:publish --tag=revisionable). Run the migration to create the revisions table. Then, on any Eloquent model you want to track, use the RevisionableTrait and define which attributes to monitor via $revisionable or $dontKeepRevisionOf properties. The first time a tracked field changes, a revision is automatically created—including optional creation logging if keepCreatedRevisions is enabled in config.
RevisionableTrait to models that need auditing (e.g., Post, User). Keep configuration lean: only specify fields in $revisionable unless excluding sensitive ones.revisionable.created, revisionable.saved, and revisionable.deleted events to trigger side effects (e.g., notify users or log to external services).$model->revisionHistory to get a reverse-chronological list of revisions. Combine with custom blade views to render diff tables (new vs old values) or use helpers like Revision::getFieldName() for label sanitization.getSystemUserId() in your model to assign revisions to authenticated users, queue workers, or CLI commands.$revisionable or $dontKeepRevisionOf to avoid logging passwords, tokens, or sensitive JSON columns.created_at/deleted_at columns are properly cast and nullable-aware.keepDeletedRevisions is enabled in config—configure carefully to avoid performance bloat.json) are handled more reliably, but complex nested structures may still require manual diffing logic in display.Revision model and overriding resolveRevisionableMorph() if custom morphs or extra fields are needed.How can I help you explore Laravel packages today?