© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
10 replies
sandofgods

Group sum summarie with query scope, not working

Hello, When i add a scope to summarie, and group my table, the group total is the same that the total

when i dont add scope its working perfectly, but i dont have the sum i need (i have to scope it...).

here my code: (when i remove the ->query it's work perfectly fine)
MoneyColumn::make("order_products_com")
                        ->label(__("commission"))
                        ->placeholder("0,00€")
                        ->color('success')
                        ->suffix('€')
                        ->formatStateUsing(function (int $state) {
                            if ($state == 0) {
                                return self::formatDisplay(self::addZeros($state));
                            } else {
                                return self::formatDisplay($state);
                            }

                        })
                        ->summarize(Sum::make()
                            ->query(fn(QueryBuilder $query) => $query->where('order_product_is_com_payed', '=', 0))
                            ->label(__("total commission"))
                            ->formatStateUsing(function (int $state) {
                                if ($state == 0) {
                                    return self::formatDisplay(self::addZeros($state));
                                } else {
                                    return self::formatDisplay($state);
                                }

                            }),
                        ),

MoneyColumn::make("order_product_sum_com_cancel")
                        ->label(__("to_take"))
                        ->color('danger')
                        ->placeholder("0,00€")
                        ->suffix('€')
                        ->formatStateUsing(function (int $state) {
                            if ($state == 0) {
                                return self::formatDisplay(self::addZeros($state));
                            } else {
                                return self::formatDisplay($state);
                            }

                        })
                        ->summarize(Sum::make()
                            ->query(fn(QueryBuilder $query) => $query->where([
                                ['order_product_is_com_payed', "=", 1],
                                ['order_product_is_com_cancel', "=", 1]
                            ]))
                            ->label(__("total to take"))
                            ->formatStateUsing(function (int $state) {
                                return self::formatDisplay($state);
                            }),
                        ),
                ])
MoneyColumn::make("order_products_com")
                        ->label(__("commission"))
                        ->placeholder("0,00€")
                        ->color('success')
                        ->suffix('€')
                        ->formatStateUsing(function (int $state) {
                            if ($state == 0) {
                                return self::formatDisplay(self::addZeros($state));
                            } else {
                                return self::formatDisplay($state);
                            }

                        })
                        ->summarize(Sum::make()
                            ->query(fn(QueryBuilder $query) => $query->where('order_product_is_com_payed', '=', 0))
                            ->label(__("total commission"))
                            ->formatStateUsing(function (int $state) {
                                if ($state == 0) {
                                    return self::formatDisplay(self::addZeros($state));
                                } else {
                                    return self::formatDisplay($state);
                                }

                            }),
                        ),

MoneyColumn::make("order_product_sum_com_cancel")
                        ->label(__("to_take"))
                        ->color('danger')
                        ->placeholder("0,00€")
                        ->suffix('€')
                        ->formatStateUsing(function (int $state) {
                            if ($state == 0) {
                                return self::formatDisplay(self::addZeros($state));
                            } else {
                                return self::formatDisplay($state);
                            }

                        })
                        ->summarize(Sum::make()
                            ->query(fn(QueryBuilder $query) => $query->where([
                                ['order_product_is_com_payed', "=", 1],
                                ['order_product_is_com_cancel', "=", 1]
                            ]))
                            ->label(__("total to take"))
                            ->formatStateUsing(function (int $state) {
                                return self::formatDisplay($state);
                            }),
                        ),
                ])

And i add a screenshot of what i get.

If you have any idea how to get this working thanks you in advance.
Capture_decran_2024-03-05_a_21.36.55.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

filament-actions::group label not working?
FilamentFFilament / ❓┊help
3y ago
Custom Filter and Query Scope
FilamentFFilament / ❓┊help
3y ago
Table builder render hooks - scope not working
FilamentFFilament / ❓┊help
4mo ago
Getting SUM of related table column not working
FilamentFFilament / ❓┊help
2y ago