Trying to delete company: Error "Can't set model as property if it hasn't been persisted yet."

This is a delete action similar to deleting a company in Laravel Jetstream. I get the error; I have to reload the page and then I get taken to the dashboard as my other company. What does this mean and what do I do to fix this?
29 Replies
Andrew Wallo
Andrew Wallo11mo ago
Does nobody know what to do here?
awcodes
awcodes11mo ago
This is something in Livewire. I’ve seen the same message in tests too when trying to test against a fake model from a package. Not sure why it would show it’s head on a delete model though. That’s weird.
Andrew Wallo
Andrew Wallo11mo ago
Does the error mean that Filament is trying to resolve the scope to the current company after its being deleted here and it can't be persisted or something?
awcodes
awcodes11mo ago
Really not sure. Seems like livewire is losing track of it. Or it’s trying to manipulate the record after it’s been deleted. Like calling save on the record although it’s been deleted. Something like that.
Andrew Wallo
Andrew Wallo11mo ago
Makes since. Do you think it's being caused by the parent EditTenantProfile page?
awcodes
awcodes11mo ago
I can’t say no, but I don’t understand why it would still have the model to even be able to call any methods on it to trigger the error. Is it soft deleted? Maybe there’s a livewire bug with softdeletes.
Andrew Wallo
Andrew Wallo11mo ago
Nope, no Soft Deletes. Just cascading everything the company owns after deletion.
awcodes
awcodes11mo ago
Yea. That’s really weird. Do you have a flare link you could share? Or is it a 500?
Andrew Wallo
Andrew Wallo11mo ago
Let me check and get it to you
Andrew Wallo
Andrew Wallo11mo ago
Flare
Can't set model as property if it hasn't been persisted yet - The error occurred at http://filament.test/company/7/profile
Andrew Wallo
Andrew Wallo11mo ago
Yeah thats the Flare url It is a 500
awcodes
awcodes11mo ago
Yea. Looks like it’s still trying to update some state with the model despite it being deleted. So it’s persisting in the livewire state somewhere. No clue if that’s on filament or livewire.
Andrew Wallo
Andrew Wallo11mo ago
Here is some more info from what the console says.
awcodes
awcodes11mo ago
Whoa. Why are you getting react errors?
Andrew Wallo
Andrew Wallo11mo ago
No clue.. Does Livewire 3 have react in it?
awcodes
awcodes11mo ago
Definitely not. But those console errors are mentioning react. And those even look like react namespaces. Weird.
awcodes
awcodes11mo ago
Andrew Wallo
Andrew Wallo11mo ago
Maybe it's something from the browser? I'm not really sure to be honest... @awcodes UPDATE: I read something online about it. So I decided to publish the livewire config and set legacy_model_binding to true. Now everything works as expected and without errors...
awcodes
awcodes11mo ago
Weird. That leads me to think it’s a synthesizer issue.
Andrew Wallo
Andrew Wallo11mo ago
ModelSynth class?
josef
josef11mo ago
Probably
awcodes
awcodes11mo ago
Synths are what makes it possible to use collections and model instances as properties. Look up wireable on livewire.laravel.com Basically they tell livewire how to hydrate and dehydrate non standard php types.
Andrew Wallo
Andrew Wallo11mo ago
Okay will do.. Will setting legacy_model_binding to true cause any issues with Filament?
awcodes
awcodes11mo ago
It shouldn’t, but i can’t say for sure.
Andrew Wallo
Andrew Wallo11mo ago
Alright. I guess I will find out. What is Filament's configuration for all of this?
awcodes
awcodes11mo ago
To my knowledge the only thing filament disables in livewire at the moment is the stupid <!— block —> placeholders. Or what ever they’re called. They screw with the state by making html checks fail. Hard to say anything though with Lw still in beta. That’s the biggest problem I’ve been having is not know if my issues are livewire, filament or me.
Andrew Wallo
Andrew Wallo11mo ago
Okay well thank you for the help in trying to find out the issue here..
awcodes
awcodes11mo ago
Wish I had a definitive answer for you.
Andrew Wallo
Andrew Wallo11mo ago
All good, with an error like that I wouldn't imagine many people to understand what the hell it means and how to fix it haha Except for maybe Caleb