Skip to content
Advertisement

restore soft delete child in laravel

I am using laravel and I want to restore child when I restore parent for example I’ve removed a user and every user has a shop so shop was deleted with $cascadeDeletes and all child related to user but when I want to restore user her/his shop won’t restore

here is Shop Model

JavaScript

and User Model

JavaScript

** I am using iatstuti/laravel-cascade-soft-deletes so is there any way with this**

Advertisement

Answer

You can add a listener for the user models restoring event and restore the related shop. In the user models boot function, add the following:

JavaScript

See model events.

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