From 2d7b619faef6aab6aa26c43e5e3c819a184c2e55 Mon Sep 17 00:00:00 2001 From: Dennis Elsinga Date: Sat, 13 Apr 2024 13:40:05 +0200 Subject: [PATCH] refactor: Improve getShouldGenerate method logic --- src/Stubs/Page/Index/Table/Summaries/Sum.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Stubs/Page/Index/Table/Summaries/Sum.php b/src/Stubs/Page/Index/Table/Summaries/Sum.php index dd1dc0aa..1a81b08d 100644 --- a/src/Stubs/Page/Index/Table/Summaries/Sum.php +++ b/src/Stubs/Page/Index/Table/Summaries/Sum.php @@ -11,7 +11,10 @@ class Sum extends Base public function getShouldGenerate(): bool { - return true; -// return $this->getResourceTableColumnsWithSummarizers($this->resource)->isNotEmpty(); + return $this->getResourceTableColumnsWithSummarizers($this->resource) + ->filter(fn($column) => collect($column->getSummarizers()) + ->filter(fn($summarizer) => $summarizer::class === \Filament\Tables\Columns\Summarizers\Sum::class) + ->count()) + ->isNotEmpty(); } }