Add Id of model in photo name during upload in form builder

how to add id of model in photo name during upload in form builder ?
2 Replies
Firebird
FirebirdOP12mo ago
FileUpload::make('photo_path')
->columnSpan(1)
->label('Image')
->disk('s3')
->directory('images/subsubcategories')
->preserveFilenames()
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName())
->prepend(SubSubCategory::all()->id),
)
->visibility('public'),
FileUpload::make('photo_path')
->columnSpan(1)
->label('Image')
->disk('s3')
->directory('images/subsubcategories')
->preserveFilenames()
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string => (string) str($file->getClientOriginalName())
->prepend(SubSubCategory::all()->id),
)
->visibility('public'),
Dennis Koch
Dennis Koch12mo ago
You could use $record->id (but only on update)
Want results from more Discord servers?
Add your server