Upload multiple images to a model
I have a
Project
model and I want the user to be able to upload many images for each project.
I'm storing the images in an images
table.
How do I allow the user to upload images and have them associated to the Project
model being created?
Solution:Jump to solution
If you use multiple() Filament expects the file paths to be saved in a json array on the model. If you want to use a morph relationship, you will want to use a relation manager or write some custom logic that will use the array, create and attach the related models, unset the data on the original model, etc.
2 Replies
Solution
If you use multiple() Filament expects the file paths to be saved in a json array on the model. If you want to use a morph relationship, you will want to use a relation manager or write some custom logic that will use the array, create and attach the related models, unset the data on the original model, etc.
Thanks Tim. I refactored my code to simply add an
images
json column to my projects
table. That did the trick. π