dimanche 17 février 2019

Laravel rollback saved changes if error is encountered while saving child model

For example, I have a User hasMany Books relationship.

Let's take this scenario.

I successfully saved the User (which is the parent model), but there was an error while saving one of the Books (which is the child model). Is it possible to delete the saved parent (only if there are errors encountered while saving the parent and/or child) then redirect to another page?

Actually I don't have any code to provide. I'm currently planning on how to build the code, and I have thought of this idea.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire