Demonstrates many features of Filament Tables: filters, summarizers, sorting, searching, header widgets, etc.
The whole table logic is in the OrderResource
Filament Resource.
Table tabs are in the ListOrders
class. For every tab, we modify the query based on the order status and show the order count for a particular status. Here is what the code to add tabs looks like:
public function getTabs(): array{ return [ 'in_progress' => ListRecords\Tab::make() ->badge(Order::where('status', OrderStatus::IN_PROGRESS->value)->count()) ->modifyQueryUsing(fn (Builder $query) => $query->where('status', OrderStatus::IN_PROGRESS->value)), 'completed' => ListRecords\Tab::make() ->badge(Order::where('status', OrderStatus::COMPLETED->value)->count()) ->modifyQueryUsing(fn (Builder $query) => $query->where('status', OrderStatus::COMPLETED->value)), 'canceled' => ListRecords\Tab::make() ->badge(Order::where('status', OrderStatus::CANCELED->value)->count()) ->modifyQueryUsing(fn (Builder $query) => $query->where('status', OrderStatus::CANCELED->value)), 'priority' => ListRecords\Tab::make() ->badge(Order::where('is_priority', true)->count()) ->modifyQueryUsing(fn (Builder $query) => $query->where('is_priority', true)), ];}
Above the table, we have a widget with three stats cards showing revenue for the current day, the last seven days, and the last 30 days. The widget must be registered in the ListOrders
class in the getHeaderWidgets
method.
Here is the...