Hi,
If soft delete is enable on Model, you can't access to his revisions because function getEntry() Backpack\CRUD\PanelTraits\Read doesn't get trashed elements.
Two options I see:
Disable revision button on trashed element (why do you want to restore a revision if element is deleted‽)
on view.buttons.revisions edit if with: @if ((isset($entry->trashed()) && !$entry->trashed()) && $crud->hasAccess('revisions') && count($entry->revisionHistory)) and test if trashed on Backpack\CRUD\app\Http\Controllers\CrudFeatures\Revisions function listRevisions($id) to abort action.
Allow getEntry to retrieve trashed element like:
public function getEntry($id)
{
$entry = $this->model->withTrashed()->findOrFail($id);
return $entry->withFakes();
}
And disable revisions restoring because you need to restore element before restoring a revision.
Maybe the second option is more relevant, because you could add a restore function like $this->crud->getEntry($id)->restore() simply.
I'm sure you'll find the best solution ! :) _(and maybe add a route for restoring ? ❤️ )_
Best regards
Tof
I'm not convinced that making getEntry($id) returned trashed entries would work (at a cursory glance this would essentially just return deleted items as well as current items to _all_ the views etc which would be bad).
In fact, I could argue that one shouldn't be able to restore to an item that's deleted (even if it is a soft delete) because that just doesn't make sense. If it's not there it's not there and I'm not sure the upstream package may have the same issue.
Hi guys,
My 2 cents on this - I think a pretty good solution already exists:
Feel free to comment if you disagree :-)
Cheers!
$this->crud->addFilter([
'type' => 'simple',
'name' => 'trashed',
'label'=> 'Trashed'
],
false,
function($values) { // if the filter is active
$this->crud->query = $this->crud->query->onlyTrashed();
});
Most helpful comment
Hi guys,
My 2 cents on this - I think a pretty good solution already exists:
Feel free to comment if you disagree :-)
Cheers!