Builder\Block::make('other_income')
->schema([
Repeater::make('other_income')
->default([
['name' => 'Laundry'],
['name' => 'Parking'],
['name' => 'Storage Rental'],
])
->schema([
TextInput::make('name')
->live()
->string()
->maxLength(255)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
}),
TextInput::make('cost')
->prefix('AED')
->live()
->numeric()
->default(0)
->minValue(0)
->maxValue(999999999)
->nullable()
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
}),
Select::make('period')
->live()
->selectablePlaceholder(false)
->enum(OtherIncomePeriod::class)
->options(OtherIncomePeriod::class)
->default(OtherIncomePeriod::PerMonth->value),
])->columnSpan(2)->maxItems(20)->itemLabel(fn (array $state): ?string => $state['name'] ?? null),
]),
])->columnSpan(2)->addable()->maxItems(1)
->collapseAllAction(
fn (Action $action) => $action->label('Collapse all content'),
),
Builder\Block::make('other_income')
->schema([
Repeater::make('other_income')
->default([
['name' => 'Laundry'],
['name' => 'Parking'],
['name' => 'Storage Rental'],
])
->schema([
TextInput::make('name')
->live()
->string()
->maxLength(255)
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
}),
TextInput::make('cost')
->prefix('AED')
->live()
->numeric()
->default(0)
->minValue(0)
->maxValue(999999999)
->nullable()
->afterStateUpdated(function (Forms\Contracts\HasForms $livewire, Forms\Components\TextInput $component) {
$livewire->validateOnly($component->getStatePath());
}),
Select::make('period')
->live()
->selectablePlaceholder(false)
->enum(OtherIncomePeriod::class)
->options(OtherIncomePeriod::class)
->default(OtherIncomePeriod::PerMonth->value),
])->columnSpan(2)->maxItems(20)->itemLabel(fn (array $state): ?string => $state['name'] ?? null),
]),
])->columnSpan(2)->addable()->maxItems(1)
->collapseAllAction(
fn (Action $action) => $action->label('Collapse all content'),
),