how to load relationship() on Forms\Components\Fieldset conditionally?

The form uses Forms\Components\Fieldset::relationship('primaryAddress') to load a related 'address' record of an user. but sometimes the user may not have the related address yet. In this case, it shows Target [Illuminate\Database\Eloquent\Model] is not instantiable. error. Is there an way to load the related 'address' record condtionally? I tried
->relationship('primaryAddress', function(Component $livewire) {
return (bool) $livewire->record->primaryAddress;
})
->relationship('primaryAddress', function(Component $livewire) {
return (bool) $livewire->record->primaryAddress;
})
, but I still get the error. thank you for your insights.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server