Table Column Relationship Sum, Avg, Max, Min, ext being ignored
I have model that consists of products. The products have a relationship of locationInventory that contain the inventory numbers for each location. On my Product Resource Table, I have a column like this:
Based on the documentation here: https://filamentphp.com/docs/3.x/tables/columns/relationships#aggregating-relationships, this should sum the total amount of quantity_in_stock for all locations. However, what I’m getting is a list of values instead.
Any pointers on what I might be doing wrong?
I have made sure the inventory values are casted to Integers and Floats, updated filament, cleared all caches.
Solution:Jump to solution
changing it to quantity_in_stock_sum made the column blank. But changing it to quantity_in_stock has it properly summing the values. Thanks for your help!
7 Replies
Forgot to attach the screen shot of the output!
I think the column name should be
quality_in_stock_sum
. They follow laravels naming schema.Solution
changing it to quantity_in_stock_sum made the column blank. But changing it to quantity_in_stock has it properly summing the values. Thanks for your help!
@Dennis Koch I’m definitely reading in the documentation that your suggestion should be correct. I guess I’m worried something else is wrong since dropping the “_sum” made it work.
Trying it three different ways,
Probably because you pass the second param manually. As long as it works all good right?
What did you change ? I still getting list .