Closed jens-andre closed 3 years ago
This is correct. The database itself is deleting the model because of the cascade delete - Fluent has no idea that it's been deleted to be able to run the middleware.
One option would be remove the cascade delete and delete the dependents in model middleware.
But capturing a cascade delete is not something Fluent will ever be able to do
Thank you very much for the quick response! How embarrassing, I should have thought of that myself. I’m very sorry for having wasted your time.
Sorry for bothering again… I removed the cascade delete but the delete action in TodoTagModelMiddleware never gets called. I created a repository, could you please take a look and test it (there is a paw file in the repo if it helps)? I also added a TodoModelMiddleware and a TagModelMiddleware which are behaving as expected.
Did you do this from a fresh database that had been completely reset or did you just change the existing migration?
I changed the migration, deleted the database and did a fresh migration.
You're not deleting the related models in your middleware?
When are you expecting your pivot middleware to be called?
No, I’m sorry, should have explained it better… When detaching the Tag I’m expecting the middleware to be called. When attaching a Tag to a Todo CREATING
and CREATED
gets printed, but not for the delete action.
To Reproduce
Expected behavior
CREATE
gets printed on attaching a tag as expected, but on detaching the tagDELETE
does not get printed.Environment