How can i do a Sum Row #1091
-
how can i achieve something like this using this package : |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
See guidance here on Footers i.e. Column::make('Price')
->sortable()
->footer(function($rows) {
return 'Subtotal: ' . $rows->sum('price');
}), |
Beta Was this translation helpful? Give feedback.
-
For your Column. I'd suggest using withSum() in your Builder function to include just the sum of your linksOrders, to avoid having to do multiple sum functions. E.g. your builder will have the following ->withSum('linksOrders', 'price') You can then reference a new sum field instead of having to do $row->linksOrders->sum('price') |
Beta Was this translation helpful? Give feedback.
-
You'll need to pass the correct field to the footer. For example Column::make("In Progress", "in_progress")
->label(fn ($row) => $fmt->formatCurrency($row->links_orders_sum_price_progress, "EUR"))
->sortable()
->footer(function ($rows) {
return $rows->sum('links_orders_sum_price_progress');
}), |
Beta Was this translation helpful? Give feedback.
You'll need to pass the correct field to the footer. For example