F
Filamentā€¢10mo ago
gigiloouu

problem with Repeater

I have problem with repeater. when im using just selection, filter works fine but when i use this same selection inside the repeater its not filter right. there is both code
Repeater::make('Brands')
->schema([
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('supplier_id') === null) {
return;
}

$brandIds = Supplier::find($get('supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})

->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),

]),
TextInput::make('amount')->required()
->required(),
])
->columns(2)
->collapsible(),
Repeater::make('Brands')
->schema([
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('supplier_id') === null) {
return;
}

$brandIds = Supplier::find($get('supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})

->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),

]),
TextInput::make('amount')->required()
->required(),
])
->columns(2)
->collapsible(),
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('supplier_id') === null) {
return;
}

$brandIds = Supplier::find($get('supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})

->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),

]),
Select::make('brand_id')
->label('Brand')
->relationship('brand', 'name', function (Builder $query, Get $get) {
if($get('supplier_id') === null) {
return;
}

$brandIds = Supplier::find($get('supplier_id'))->brand_id;
$query->whereIn('id', $brandIds);
})

->createOptionForm([
TextInput::make('name')
->required()
->label('New Brand'),

]),
13 Replies
gigiloouu
gigiloouuOPā€¢10mo ago
i have logic that if i choose supplier(another selection) its takes next brand by supplier.brand_ids and this logic doesnt works like its alwyas get all brands
Dennis Koch
Dennis Kochā€¢10mo ago
I think you need $get('./supplier_id') because otherwise it's looking for the field inside the repeater Maybe also $get('../supplier_id')
gigiloouu
gigiloouuOPā€¢10mo ago
neither doest works
Dennis Koch
Dennis Kochā€¢10mo ago
Check what $get returns and start debugging from there.
gigiloouu
gigiloouuOPā€¢10mo ago
its return null i try ../ ./ but not works for that wwhy its cant read it.. any idea? @Dennis Koch
Dennis Koch
Dennis Kochā€¢10mo ago
Not really. Can you share the rest of the form?
gigiloouu
gigiloouuOPā€¢10mo ago




gigiloouu
gigiloouuOPā€¢10mo ago
there is full form šŸ˜„ down of Repeater i have same select for brand there everything works but in Repeater i have same select and also Textinput for amount problem is that inside the repeater 'supplier_id' is alwyas null
Dennis Koch
Dennis Kochā€¢10mo ago
$get('../supplier_id') should be the right one in this case.
gigiloouu
gigiloouuOPā€¢10mo ago
it not working i try ../ also ./ but not working..
if($get('../supplier_id') === null) {
if($get('../supplier_id') === null) {
../../ works.. huh thanks
Dennis Koch
Dennis Kochā€¢10mo ago
Hm, weird. You're only 1 level deep? Or did I overlook something? šŸ¤”
gigiloouu
gigiloouuOPā€¢10mo ago
idk i just try ~/ also ./ ../ but at last ../../ this worked d i have no idea why or how but its works so who gives a fuck šŸ˜„
Want results from more Discord servers?
Add your server