spatie media library - multiple image fields on a resource
Good morning folks - a newbie question so apologies.
I have a product resource that I need to have an icon, a preview image and a gallery of images - I though that the spatie media library would enable me to do this - in my resource form schema I have the following
Forms\Components\Tabs\Tab::make('Images')
->schema([
SpatieMediaLibraryFileUpload::make('preview'),
SpatieMediaLibraryFileUpload::make('icon'),
SpatieMediaLibraryFileUpload::make('images')
->multiple()
]),
However, when I upload an image into the preview 'panel', the image is then replicated across the other File uploads - its as if they are not being treated as seperate fields. What am I doing wrong?
Any advice would be greatfully received
Jon
1 Reply
Apologies - I have just read about collections and that has done the trick - so my schema definition now looks like
Forms\Components\Tabs\Tab::make('Images')
->schema([
SpatieMediaLibraryFileUpload::make('preview')
->collection('preview'),
SpatieMediaLibraryFileUpload::make('icon')
->collection('icon'),
SpatieMediaLibraryFileUpload::make('images')
->collection('images')
->multiple()
]),
Thats created a separation of concerns.