Dos
Optionally adding a morthOne relationship for the resource form
There is an Item model with a morphOne relationship to the Attachments model.
In the ItemResource form when creating an Item, the ability to add an attachment for the item is also added, but it should be optional, not mandatory.
The problem is that if I don't load the attachment, an error is returned because when I create Item at the same time it tries to create the Attachment relationship on null
I would appreciate if anyone advise me If there is a way to add an attachment optionally ItemResource form?
Section::make('Attachments')->schema([
FileUpload::make('url')
->required()
->downloadable()
->label('File'),
])->relationship('attachments')
8 replies