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)
    ))
Was this page helpful?