FilamentF
Filamentβ€’3y ago
Husky110

Filter gets applied automatically?

Hey again - sorry if my questions are a bit noob-like, I just try to get filament figured out... πŸ™‚
This time I have a weird behaviour. I want to show some articles in my table. For that my table actually uses a morphed-model which has an "article"-relationship.
What I want: Show only articles where article.is_locked = 0 and make articles with article.is_locked = 1 only visible if a filter is active.
I got so far to build a filter like this:
Tables\Filters\Filter::make('article.is_locked')
                    ->query(function (Builder $query){
                        $query->whereHas('article', function ($subquery){
                            $subquery->where('is_locked', 1);
                        });
                    })
                    ->label(__('articles.list.filters.is_locked'))
                    ->toggle()

But this filter seems to get applied automatically, so right now I only see locked articles even tho the filter is not active.
My two questions here are: Is this normal an intended? And secondly - I am sure I am missing something here, but I need help figuring out what exactly.
Thanks. πŸ™‚
Was this page helpful?