Are you using : https://github.com/laravel-backpack/revise-operation (that use VentureCraft/revisionable). Or the https://github.com/VentureCraft/revisionable with a backpack CRUD project ?
For what I know, the revisions are saved per field in a model that has the revisionable trait.
The trait VentureCraft/revisionable
doesn't include a scope to narrow et get the value per, as you would like (->revision
).
To achieve that, you should implement a function on your model to switch the model value to a revision id.
Like (roughly) :
public function previewAsRevision($revision_id) {
// 1. Get the current model's field values.
// 2. Get the target revision by $id to get the field modified and both old and new value.
// 3. temporary change the $this->$field_name value to the revision value.
// 4. return the temporary Model object with the modified value.
//kindish and depends on what are the operations needed to be done with this.
}
To implement this as a scope
, it's different. Because each field change creates a new revision entry.
Maybe you would like to see which Todo as its origin values and its currents. That would be possible, since we can get each field that has a revision, and rewind back to the first oldValue
.
Anyhow, hopes this help or narrow the solution for you.