F
Filament3mo ago
Tjiel

Duplicate query problem when using a relationship in a repeater

Hey all, I have the following repeater:
Repeater::make('answers')
->label('Answers')
->translateLabel()
->relationship('answers')
->schema([
Forms\Components\TextInput::make('name')
->label('Answer')
->translateLabel()
->required()
->maxLength(255)
->default(''),
])->reorderable()->orderColumn('order'),
Forms\Components\Select::make('section_id')
->label('Section')
->translateLabel()
->preload()
->live()
->relationship('section', 'name'),
Repeater::make('answers')
->label('Answers')
->translateLabel()
->relationship('answers')
->schema([
Forms\Components\TextInput::make('name')
->label('Answer')
->translateLabel()
->required()
->maxLength(255)
->default(''),
])->reorderable()->orderColumn('order'),
Forms\Components\Select::make('section_id')
->label('Section')
->translateLabel()
->preload()
->live()
->relationship('section', 'name'),
But the problem is that for each answer the section query is performed instead of it being performed once. Is there a good way to make it so the following query: select * from sections where sections.id = 15 limit 1, is only being made once instead of for each answer once.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server