Repeater Component only showing one record despite HasMany relationship

Hi Guys! I have a question regarding the repeater component that has a relationship. The way I have it setup, "works" but its only showing one entry(the last one), and not all the entries. So I have a repeater in my waybillResource:
$repeaterField = Repeater::make('CONTENTS')
->schema([
TextInput::make('DESCRIPTION')->label('Desc')->required(),
TextInput::make('DIM1')->label('Dim1')->required(),
TextInput::make('DIM2')->label('Dim2')->required(),
TextInput::make('DIM3')->label('Dim3')->required(),
TextInput::make('ACTMASS')->label('Weight')->required(),
])
->relationship('CONTENTS')
->defaultItems(0)
->columnSpanFull()
->columns(5);
$repeaterField = Repeater::make('CONTENTS')
->schema([
TextInput::make('DESCRIPTION')->label('Desc')->required(),
TextInput::make('DIM1')->label('Dim1')->required(),
TextInput::make('DIM2')->label('Dim2')->required(),
TextInput::make('DIM3')->label('Dim3')->required(),
TextInput::make('ACTMASS')->label('Weight')->required(),
])
->relationship('CONTENTS')
->defaultItems(0)
->columnSpanFull()
->columns(5);
In my waybill model:
public function CONTENTS(): HasMany
{
return $this->HasMany(Contents::class, 'WAYBILL');
}
public function CONTENTS(): HasMany
{
return $this->HasMany(Contents::class, 'WAYBILL');
}
And in my contents model:
public function WAYBILL(): BelongsTo
{
return $this->BelongsTo(Waybill::class, 'WAYBILL');
}
public function WAYBILL(): BelongsTo
{
return $this->BelongsTo(Waybill::class, 'WAYBILL');
}
It looks like both records are getting fetched, since if I dump the data in the beforeFill() method, I can see 2 records present:
protected function beforeFill(): void
{
$items = $this->record->contents->toArray();
dd('beforeFill', $this->record, $items[0], $items[1]);
}
protected function beforeFill(): void
{
$items = $this->record->contents->toArray();
dd('beforeFill', $this->record, $items[0], $items[1]);
}
Am I missing something obvious here? How do I get both records to show up in the repeater? Any help would be greatly appreciated!
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server