FilamentF
Filament3y ago
Wim

FileUpload with dynamic folder name

I'm using Filament to upload product images. I would like to create a folder structure as follows:
/images/product1/image1.png, /images/product1/image2.png ....  /images/productN/image1.png, /images/productN/imageN.png. 
Hence I would like to use the product name (product1...productN) in the ->directory() method. Anyone could provide an example on how to do this?
Solution
Assuming you have a 'slug' field you can do
->directory(fn ($get) => $get('slug'))
Was this page helpful?