Trying to have FileUpload works with my table

->How can I have fileupload to work with my DB structure ? Actually my images table is a polymorph table I have my component like that
Forms\Components\Fieldset::make('Featured Image')
->relationship('featuredImage')
->schema([
Forms\Components\FileUpload::make('file_name')
->disk('s3-public')
->directory('image/resource/1/1/4/114/')
->previewable(true)
->preserveFilenames()
->visibility('public')
->image()
]),
Forms\Components\Fieldset::make('Featured Image')
->relationship('featuredImage')
->schema([
Forms\Components\FileUpload::make('file_name')
->disk('s3-public')
->directory('image/resource/1/1/4/114/')
->previewable(true)
->preserveFilenames()
->visibility('public')
->image()
]),
->directory seems to doesn't work too. If I Put the image at the root of my disk, the image is displayed; but not if my image is in image/resource/1/1/4/114/ What do I need to change the saving process and use my own column ?
No description
5 Replies
Dennis Koch
Dennis Kochβ€’4mo ago
->directory seems to doesn't work too
->directory() just sets where to store the file. It still stores the whole filepath from the root of the disk in the database. You could try ->getStateUsing() to add the directory as a prefix
! GhostvOne.tv πŸ‘»πŸ‡«πŸ‡·
I'm in a form builder and I don't find where to use getStateUsing ?
Dennis Koch
Dennis Kochβ€’4mo ago
Wait, sorry. I think that only works for table columns I think it's either: - Updating the DB to include the directory - Mutating the state of the FileUpload field through mutateFormDataBeforeFill() on the EditPage
! GhostvOne.tv πŸ‘»πŸ‡«πŸ‡·
Thanks for you help, i'm using mutateFormDataBeforeFill Now how can I change/overide upload and delete action ?
Dennis Koch
Dennis Kochβ€’4mo ago
Delete Action probably doesn't need adjustment as it just removes an item from an array? I think upload can changed via saveUploadedFilesUsing() or similar method
Want results from more Discord servers?
Add your server