Use the Repeater field and live methods to create an invoice with parent/children records, calculating the subtotal/total with taxes in live mode.
The main logic lives in our InvoiceResource
and is mainly contained within the form()
method:
Repeater
field to allow adding multiple itemslive()
method to calculate the subtotal and total in real timeitems
list change, quantity changeHere's how it looks in the code:
app/Filament/Resources/InvoiceResource.php
// ... class InvoiceResource extends Resource{ public static function form(Form $form): Form { $products = Product::get(); return $form ->schema([ Forms\Components\TextInput::make('customer_name') ->required() ->maxLength(255), Forms\Components\TextInput::make('customer_email') ->email() ->required() ->maxLength(255), Section::make() ->columns(1) ->schema([ // Repeatable field for invoice items Forms\Components\Repeater::make('invoiceProducts') // ...