Filter queries not override the eloquent query

Hi there!
I have a FIlter in my Table Builder, in which I would like to filter by a computed property setted in resource main page, eloquent query method. I have check that the query works fine at SQL editor.
When I apply the ->query() method from filter, it overrides the eloquent query and the field is not found. How to manage it??
              Filter::make('available_slots')
                    ->form([
                        TextInput::make('qtat')
                            ->label('Aforament mínim')
                            ->numeric()
                    ])
                    ->query(function (
                        Builder $query,
                        array $data
                    ): Builder {
                        // it overrides $livewire->getTableQuery()
                        return $query
                            ->when(
                                $data['qtat'],
                                function (
                                    Builder $query,
                                    $availableSlots,
                                ): Builder {
                                    return $query->having('available_slots',
                                        '>=', $availableSlots);
                                });
                    })
Solution
This function is doing the trick.
Was this page helpful?