make repeater validation
I have Repeater where i can add many blogs. this blogs has amount. this blogs amount sum should not be more then
sum amountsum amount . I want to make validation if first brand amount is 500 and second brand amount i wrote 300 and sum amountsum amount === 600 second brand amount should have erorr that max value is 100. there is my code: php
Repeater::make('purchaseBrands')
->relationship()
->schema([
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('../../supplier_id') === null) {
return $query;
}
$brandIds = Supplier::find($get('../../supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})
->searchable()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
->required()
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),
TextInput::make('brand_amount')
->numeric()
->required()
]),
TextInput::make('amount')->required()
->required()
->numeric()
->live()
->maxValue()
])
->columns(2)
->addActionLabel('add blog')
->collapsible(),php
Repeater::make('purchaseBrands')
->relationship()
->schema([
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('../../supplier_id') === null) {
return $query;
}
$brandIds = Supplier::find($get('../../supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})
->searchable()
->disableOptionsWhenSelectedInSiblingRepeaterItems()
->required()
->preload()
->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),
TextInput::make('brand_amount')
->numeric()
->required()
]),
TextInput::make('amount')->required()
->required()
->numeric()
->live()
->maxValue()
])
->columns(2)
->addActionLabel('add blog')
->collapsible(),