F
Filament14mo ago
NoxyArg

Repeater sum Items and quantities

I have a problem, I have a repeater and I want to calculate the items and quantities, create a placeholder inside the repeater with the subtotal of the item, and a placeholder outside the repeater to calculate all the added items * quantities, until then it works perfectly, the problem I have is if I add more quantity, it doesn't update the total that is outside the repeater, any ideas? Repeater::make('invoiceItems')... TextInput::make('article_quantity')... TextInput::make('article_price')...

Placeholder::make('subtotal') ->content(function ($get) { $ar_price = intval($get('article_price')); $ar_qty = intval($get('article_quantity')); $sub = $ar_price * $ar_qty; return '$' . number_format($sub, 2); }),
Outside the repeater ......

Placeholder::make('Total') ->content(function ($get) { return collect($get('invoiceItems')) ->pluck('subtotal') ->sum(); }),
No description
No description
1 Reply
Adnan Yalahow
Adnan Yalahow13mo ago
i think you should try helperText function for the repeater it takes state so just add all the sub totals and return the total it will show up at the bottom of the repeater
Want results from more Discord servers?
Add your server