Support the ongoing development of Laravel.io →
posted 11 years ago
Packages

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...

Last updated 3 years ago.
0

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?

Last updated 3 years ago.
0

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.

Last updated 3 years ago.
0

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

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.