© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
7 replies
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( ... );
                }
            })
->modifyQueryUsing(function (Builder $query, Table $table): void {
                if($table->getColumns()['expensive_column']->isVisible()){
                    $query->withSum( ... );
                }
            })
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Exporter: Modify Query based on Options?
FilamentFFilament / ❓┊help
2y ago
Filter query based on column value
FilamentFFilament / ❓┊help
3y ago
Modify query on AttachAction
FilamentFFilament / ❓┊help
2y ago
table column visibility base on record
FilamentFFilament / ❓┊help
3y ago