From c5c52c59e5a55dd25a6a4fe6b4c344250ca1ddbf Mon Sep 17 00:00:00 2001 From: D-Jordy Date: Thu, 20 Jun 2024 10:24:57 +0200 Subject: [PATCH] Update documentation --- packages/tables/docs/07-summaries.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/tables/docs/07-summaries.md b/packages/tables/docs/07-summaries.md index b4e86c18ad..648e6502cb 100644 --- a/packages/tables/docs/07-summaries.md +++ b/packages/tables/docs/07-summaries.md @@ -332,6 +332,20 @@ TextColumn::make('name') The callback has access to the database `$query` builder instance to perform calculations with. It should return the value to display in the table. +## Hiding the summary + +To hide a summary conditionally, you may use the `hidden()` method: + +```php +use Filament\Tables\Columns\Summarizers\Summarizer; +use Filament\Tables\Columns\TextColumn; +use Illuminate\Database\Eloquent\Builder; + +TextColumn::make('name') + ->summarize(Summarizer::make() + ->hidden(fn(Builder $query): bool => $query->count() == 0)) +``` + ## Summarising groups of rows You can use summaries with [groups](grouping) to display a summary of the records inside a group. This works automatically if you choose to add a summariser to a column in a grouped table.