In Wordpress, I am able to revert to previous versions of pages/posts, and I was wondering if we have anything similar?
In theory, it seems fairly straight forward - record the database and id of the record being edited, store the whole record or part as a json string, and the user id of the editor. maybe make it selective, as maybe not all tables need their changes recorded.
Theory & Practice often are very different, however...
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