Skip to content
Advertisement

Laravel Varbox how can I extend the Revision model

I’m using Varbox admin panel inside a Laravel project. The HasRevisions trait on my Article custom entity and everything works as expected.

However, recently I’ve extended the revisions database table to also support soft deleting by adding a deleted_at column, but I don’t know how to actually extend the Revision model to support soft deleting.

Can someone please help?

Thanks a lot!

Advertisement

Answer

As with most custom developed functionalities inside Varbox, you have the option of overwriting the bindings.

This means that you can swap the VarboxModelsRevision model with your own implementation and Varbox will take care of using your implementation everywhere.

To overwrite the revision model binding, go to config/varbox/bindings.php and change the value for revision_model:

JavaScript

Once that’s done, you can write your soft deleting behavior inside your model.

The easiest way to conform with the requirements of the revision model is to extend your own model with the Varbox one, or at least implement the VarboxContractsRevisionModelContract

JavaScript

Here’s the documentation part for reference: https://varbox.io/docs/1.x/model-revisions#overwrite-bindings

Also, you might want to learn about overwriting bindings: https://varbox.io/docs/1.x/custom-bindings

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement