How can I aggregate a field on a pivot table with TextColumn->sum()?

My code:
TextColumn::make('locations_sum_available_quantity')
->label('Inventory')
->sum('locations', 'inventories.available_quantity')
->badge()
->alignCenter()
->sortable(),
TextColumn::make('locations_sum_available_quantity')
->label('Inventory')
->sum('locations', 'inventories.available_quantity')
->badge()
->alignCenter()
->sortable(),
I can't seem to get this to work. Is it possible to aggregate a field on the pivot table?
Solution:
Figured it out. Tinkerwell to the rescue. Solution:...
No description
Jump to solution
1 Reply
Solution
morty
morty5w ago
Figured it out. Tinkerwell to the rescue. Solution:
TextColumn::make('locations_sum_inventoriesavailable_quantity')
->label('Inventory')
->sum('locations', 'inventories.available_quantity')
->badge()
->alignCenter()
->sortable(),
TextColumn::make('locations_sum_inventoriesavailable_quantity')
->label('Inventory')
->sum('locations', 'inventories.available_quantity')
->badge()
->alignCenter()
->sortable(),
No description

Did you find this page helpful?