public static function form(Form $form): Form
{
Repeater::make('items')
->schema([
TextInput::make('title'),
TextInput::make('qty')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('rate')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('discount')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('line_total')
->live(),
]),
TextInput::make('subtotal')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('discount')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('tax')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('total')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
}
public static function form(Form $form): Form
{
Repeater::make('items')
->schema([
TextInput::make('title'),
TextInput::make('qty')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('rate')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('discount')
->live()
->afterStateUpdate(function (Get $get, Set $set) {
self::updateLineTotal($get, $set);
}),
TextInput::make('line_total')
->live(),
]),
TextInput::make('subtotal')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('discount')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('tax')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
TextInput::make('total')
->live()
->afterUpdateHydrated(function (Get $get, Set $set) {
self::updateTotals($get, $set);
})
->readOnly(),
}