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
Does nobody know what to do here?
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.
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?
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.
Makes since. Do you think it's being caused by the parent
EditTenantProfile
page?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.
Nope, no Soft Deletes. Just cascading everything the company owns after deletion.
Yea. That’s really weird. Do you have a flare link you could share?
Or is it a 500?
Let me check and get it to you
See if this works: https://flareapp.io/share/RmroxnlP
Flare
Can't set model as property if it hasn't been persisted yet - The error occurred at http://filament.test/company/7/profile
Yeah thats the Flare url
It is a 500
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.
Here is some more info from what the console says.
Whoa. Why are you getting react errors?
No clue.. Does Livewire 3 have react in it?
Definitely not. But those console errors are mentioning react.
And those even look like react namespaces. Weird.
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...Weird. That leads me to think it’s a synthesizer issue.
ModelSynth
class?Probably
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.
Okay will do.. Will setting
legacy_model_binding
to true cause any issues with Filament?It shouldn’t, but i can’t say for sure.
Alright. I guess I will find out. What is Filament's configuration for all of this?
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.
Okay well thank you for the help in trying to find out the issue here..
Wish I had a definitive answer for you.
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