FilamentF
Filament3y ago
jim

Conditionally modify query based on column visibility

Does anyone know a way to conditionally modify a Table query based on the visibility of a column? I've got a couple of columns that are based on withSum, and I'd rather not have them as part of the base query if they aren't being shown.
Solution
Ahhh...thanks @K R A T O S and @Brian Kidd that put me on the right path...this works perfectly for what I want it to do.
->modifyQueryUsing(function (Builder $query, Table $table): void {
                if($table->getColumns()['expensive_column']->isVisible()){
                    $query->withSum( ... );
                }
            })
Was this page helpful?