404 on model deletion #406
Replies: 4 comments
-
Hi @bjhfransen, I am facing exactly the same problem in a quite similar setup. Did you manage to find a solution for this? |
Beta Was this translation helpful? Give feedback.
-
Any solution to this problem? I guess when modal is closed after deleting, that time reset state is called and it doen't found the record and give 404. Can we avoid calling resetState? Or do we need to change config value? |
Beta Was this translation helpful? Give feedback.
-
This issue comes from Livewire not from wire-elements modal. Livewire hydrates all the models including the one deleted. |
Beta Was this translation helpful? Give feedback.
-
I fixed this problem. No need to use softdeletes too. Don't use any mode class in your mount method, instead use primary id. Then use Model::find(id) and then delete it. If you use model class directly and deletes it, it will delete from database and you will find empty value for that model when livewire refreshes it. If required any assistance can reply here. |
Beta Was this translation helpful? Give feedback.
-
Creating and updating modals are working fine, but when I have a modal that asks for a confirmation to delete a given model I get a 404 and all modals are broken (all showing 404). I feel it's somewhere in the rehydration mechanics of the package. Tried to look into it and see if I could invoke the destroyComponent method and populate it with the activeComponent property. But to no avail. Went down in the inner workings of Livewire, events and hydration - but while I've learned a thing or two I din't find an answer there. I tried to comment of portions of logic, but also not the solution. Currently I'm down 8 hours trying to find clues in the inner workings of the package, but I ran out of ideas to tackle it. Thought it might be an issue.
Logic:
Issue:
Solution:
Image of confirmation modal
Image of the 404 happening (this happens to all elements that can call a modal; in my case for creating a new character, updating an existing one from the overview with cards, or deleting another one from the overview with cards)
From DeleteCharacter (modal)
From CharactersOverview (parent component, holding all the cards)
From CharactersOverview too
Beta Was this translation helpful? Give feedback.
All reactions