© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
13 replies
aacarrion4

Hide all records in the table

Hi, I have a question: how can I hide all records in the table as long as a filter option is not selected?

For example, records should only appear when I select an academic period; otherwise, nothing should appear in the table.
image.png
image.png
Solution
Thank you very much, I have modified it a little and it worked.

->modifyQueryUsing(fn ($query, $livewire) => $query
    ->when(
        blank($livewire->tableFilters),
        fn ($query) => $query->whereRaw('1 <> 1')
    )
    ->when(
        $livewire->tableFilters['academic_period_id'] ?? null,
        fn ($query, $academic_period_id) => $query->where('academic_period_id', $academic_period_id)
    )
    ->when(
        $livewire->tableFilters['course_id'] ?? null,
        fn ($query, $course_id) => $query->where('course_id', $course_id)
    ))
->modifyQueryUsing(fn ($query, $livewire) => $query
    ->when(
        blank($livewire->tableFilters),
        fn ($query) => $query->whereRaw('1 <> 1')
    )
    ->when(
        $livewire->tableFilters['academic_period_id'] ?? null,
        fn ($query, $academic_period_id) => $query->where('academic_period_id', $academic_period_id)
    )
    ->when(
        $livewire->tableFilters['course_id'] ?? null,
        fn ($query, $course_id) => $query->where('course_id', $course_id)
    ))
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Table not Listing All Records
FilamentFFilament / ❓┊help
6mo ago
Table Actions in Relation Manager reflect in all table records
FilamentFFilament / ❓┊help
2y ago
table group only results in querying all records
FilamentFFilament / ❓┊help
2y ago
table does not display all records
FilamentFFilament / ❓┊help
3y ago