Table with Records (no Query) crashes while using summarize
Im using a table with static records and want to show a sum at the end of the table with the summarize method.
Here is my code:
Here the error i get:
getTableSummarySelectedState(): Argument #1 ($query) must be of type Illuminate\Database\Eloquent\Builder, null given
The function needs a query instance to work but apparently there is none:
Solution:Jump to solution
GitHub
[4.x] Table summarize with custom data · Issue #17286 · filamentp...
Package filament/filament Package Version v4.0.0 Laravel Version v12.23.1 Livewire Version v3.0.0 PHP Version PHP 8.4.11 Problem description When declaring a table either through the Widget menu or...
8 Replies
Kind of a fix to give the table an empty query...it works but there should be a better way.
How do you summarise static data? Last time I looked it was not supported.
Oh okay i didnt know it was not supported thats good to know because i thought its just a bug or a scenario nobody thought about.
Everybody should know that my "fix" is nowhere best practice but it works for me for now.
Maybe in the future when i have time i could try to make a pr but right now i dont have the time.
You can also see ive implemented my own "liveEntangleSelection" with a quick composer patch.
That functionality would be nice in the future aswell (maybe another pr of me when i got time).
I use the live entanglement to show a sum for all selected entries which was an requirement of our customer.
I thought all those summarizers work on the DB level, so I'm surprised you got some results. Might be wrong though.
@Dan Harrin I don't think we support summarisers on custom data (at least we don't mention it in the docs), but looks like it's not too hard to add with custom Summarizers. Should this work?
have you checked if theres an issue open for it
Nope, I considered this as "not supported" for now, so I didn't look for bugs 😅
Solution
GitHub
[4.x] Table summarize with custom data · Issue #17286 · filamentp...
Package filament/filament Package Version v4.0.0 Laravel Version v12.23.1 Livewire Version v3.0.0 PHP Version PHP 8.4.11 Problem description When declaring a table either through the Widget menu or...
Ah i missed that ticket - sorry
FYI: my empty query i added is not running at all so its just there to fix the error
I will drop my quick fix in there for now so people can use it for now