F
Filamentβ€’4mo 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
gigiloouuβ€’4mo 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β€’4mo 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
gigiloouuβ€’4mo ago
neither doest works
Dennis Koch
Dennis Kochβ€’4mo ago
Check what $get returns and start debugging from there.
gigiloouu
gigiloouuβ€’4mo ago
its return null i try ../ ./ but not works for that wwhy its cant read it.. any idea? @Dennis Koch
Dennis Koch
Dennis Kochβ€’4mo ago
Not really. Can you share the rest of the form?
gigiloouu
gigiloouuβ€’4mo ago




gigiloouu
gigiloouuβ€’4mo 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β€’4mo ago
$get('../supplier_id') should be the right one in this case.
gigiloouu
gigiloouuβ€’4mo 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β€’4mo ago
Hm, weird. You're only 1 level deep? Or did I overlook something? πŸ€”
gigiloouu
gigiloouuβ€’4mo 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
More Posts