Reputation: 1431
Prior to Laravel/Eloquent I liked the model of adding a valid from and valid to date on records that required version control in the data base. This allowed me to pull in the most recent record quite easily (where valid from is less than today and valid to is null) as well as provide easy viewing of the versions. This is probably not the most efficient way to version control but does keep things quite simple.
However, now moving to Laravel 5.6 with Eloquent, as a total newbee, is there a clever way which this can be taken care of? Are valid from/valid to columns still a good way to do this? What are your recommendations on a simple way to version control records in a table?
Upvotes: 3
Views: 3106
Reputation: 4170
The package github.com/mpociot/versionable is comparatively recent.
Or check www.laravel-auditing.com/docs/9.0/getting-audits for another nice solution.
There is no explicit mentioning of date-based versioning as you wanted. Versioning is usually organized by creating a version when one is saved, not when a certain date has been reached.
When showing versions by date it's easy enough to create a select box with date ranges or a from
<=>to
date input and programming a where
clause according to the selection.
Upvotes: 2