filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.

Home Page:https://filamentphp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Summary makes field which using getStateUsing ignored

raiika opened this issue · comments

Package

filament/filament

Package Version

v3.2

Laravel Version

v11.9

Livewire Version

No response

PHP Version

v8.3

Problem description

In table builder, when you use getStateUsing or formatStateUsing and also use summary with the same column name,
the field which using the thoseStateUsing will be ignored and returning the original column (if not original column, it will return empty).

image

Expected behavior

The field column should still return the expected result even if it is using summary function.

Steps to reproduce

Table builder example

TextColumn::make('field')
    ->getStateUsing(fn () => 1),
TextColumn::make('field')
    ->summarize([
        Summarizer::make()
            ->label('Sum')
            ->using(fn () => 1)
    ]),



TextColumn::make('name')
    ->formatStateUsing(fn (): View => view(
            'test_field_2'
        )),
TextColumn::make('name')
        ->summarize([
            Summarizer::make()
                ->using(fn () => 2)
        ]),

Reproduction repository

https://github.com/raiika/filament-issue-summary

Relevant log output

No response

Summaries execute SQL queries to calculate results. If we didn't do that, they would be very slow, especially the summary row that calculates across multiple pagination pages.

You can use a custom summary to do the calculation using your own function. This could involve doing a $query->get() and then using the model results: https://filamentphp.com/docs/3.x/tables/summaries#custom-summaries