Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save A909M/a7cf6a851fb5046800880eb9bc314455 to your computer and use it in GitHub Desktop.
Save A909M/a7cf6a851fb5046800880eb9bc314455 to your computer and use it in GitHub Desktop.
If you have too many records in a single table to show immediately, you can hide them until a filter/search is applied.
->modifyQueryUsing(function (Builder $query, $livewire) {
$hasFilters = collect($livewire->tableFilters)
->filter(fn($filter) => !empty($filter['values']))
->isNotEmpty();
return ($livewire->hasTableSearch() || $hasFilters) ? $query : $query->whereRaw('1 = 0');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment