How to ignore save relation when FileUpload is empty?
I have this code:
If FileUpload was empty when saving, its return error cause trying to save the relation. Any way to skip the saving relation when FileUpload empty?
2 Replies
maybe using beforeCreate/beforeSave?
https://filamentphp.com/docs/2.x/admin/resources/creating-records#lifecycle-hooks
Filament
Creating records - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
I'll check if I can ignore saving relation from their.
btw, I already did it by using
->saveRelationshipsUsing($record, $state)
. If filled $state, then, save the relation as you need using $record and the content of $state. Just looking if there's a simple/direct method to do that.