lundi 28 janvier 2019

Laravel - updateOrCreate or a sync method?

I'm trying to see what my best route should be but for the sake of ease I will make this sound much simpler than it is.

I have two models, one called donor and one called donation. For the relationships, the donor has many donations.

In my edit form of the donor model, I have the ability to create, update or delete the donations from the same form.

Updating and creating are easy at the moment because I can use updateOrCreate. But what happens if I want to delete a donation?

Would I perform an actual query filtering out the ids of the donations that were still on the edit form (and therefore not deleted by the user) and then delete the models from there? Or is there a better way of handling this action?

Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2HCPxK9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire