If you have too many records in a single table to show immediately, you can hide them until a filter/search is applied.
Let's start by adding tabs functionality to the table. To do this, let's modify our ListOrders
file:
app/Filament/Resources/Orders/Pages/ListOrders.php
// ... public function getTabs(): array{ return [ 'all' => Tab::make(), 'completed' => Tab::make() ->modifyQueryUsing(fn(Builder $query) => $query->where('status', OrderStatus::Completed->value)), 'refunded' => Tab::make() ->modifyQueryUsing(fn(Builder $query) => $query->where('status', OrderStatus::Refunded->value)), ];} // ...
Once that is done, let's modify the OrdersTable
file to add the logic that will prevent the table from displaying any entries unless searched or filtered:
app/Filament/Resources/Orders/Tables/OrdersTable.php
use Illuminate\Database\Eloquent\Builder;use App\Filament\Resources\Orders\Pages\ListOrders; // ...
Next, we will add: