Relational data in Infolist is not shown
I’m creating a ticket system, but somehow the relational data in the replies info list is not populated. However, the data is queried if I look in the Laravel debugger. And if I DD($this->ticket), I can see the replies. What am I doing wrong?
The infolist:
public function viewReplies(Infolist $infolist): Infolist
{
return $infolist
->record($this->ticket)
->schema([
\Filament\Infolists\Components\Section::make('Replies')
->relationship('replies')
->schema([
RepeatableEntry::make('replies')
->schema([
TextEntry::make('content')
->label('Reply Content'),
])
->columnSpan('full'),
]),
]);
}
The bladefile:
<x-filament-panels::page>
{{ $this->viewTicket }}
{{ $this->viewReplies }}
{{ $this->createReply }}
<x-filament-panels::form.actions :actions="$this->getFormActions()" />
</x-filament-panels::page>
The model:
public function replies(): HasMany
{
return $this->hasMany(Reply::class);
}
The rest of the code is attached.Solution:Jump to solution
Found the error. Since the relationship 'replies' are accessed trough the record, there's no need to define:
->relationship('replies')
I just deleted it. Works....
2 Replies
Bump
Solution
Found the error. Since the relationship 'replies' are accessed trough the record, there's no need to define:
->relationship('replies')
I just deleted it. Works.