I have a couple of cases where I do this - typically I just soft-delete the old record and insert the new one (the trade-off being that you can't use composite keys in this way). If I want a full revision history I add withTrashed()
to the query.
I suppose a package that adds a pre-update hook to do this could work?
I believe WordPress stores a row for each of the revisions, and uses a column to specify whether or not each row is a revision or the most current (active) post.
This would be very easy to implement in Laravel with scopes.
I have a project where I need an audit trail of all edits - I have a base model that writes to an audit table with the old/new values json encoded
Note this isn't used for rollbacks etc, but purely to audit who made what changes
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community