Skip global scope on open modal and try to fetch record data.
Hello, everyone!
I'm using Filament PHP in my project. I’ve applied a global scope to one of my models to filter records, and it works as expected in most cases.
However, I’ve noticed an issue: if I try to fetch the same record again, the global scope is skipped. After investigating, I found that Livewire seems to fetch the record from ModelSynth. Here’s the relevant part of the code:
The issue seems to be with the newQueryForRestoration method, which fetches the record without applying global scopes:
If I modify the hydrate function in ModelSynth.php like this:
...it works perfectly, as it applies the global scope during the query.
My Livewire version: 3.5.4
My Questions:
1. Is there a better way to handle this without modifying Livewire’s core?
2. Why does Livewire skip global scopes in newQueryForRestoration? Is this intentional behavior?
3. Can I override this behavior in my Filament project to ensure global scopes are applied?
4. Is this a filament issue or livewire issue.
Thanks in advance for your help!
0 Replies