Spatie Media library in Relation Manager

Hi everybody, I have a SpatieMediaLibrary component in a Relation Manager, but I want only to allow downloading files. I have for now:
public function form(Form $form): Form
{
return $form
->schema([
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->downloadable()
->columnSpanFull()
->deletable(false)
->label('Attachments')
]);
}
public function form(Form $form): Form
{
return $form
->schema([
SpatieMediaLibraryFileUpload::make('attachments')
->multiple()
->downloadable()
->columnSpanFull()
->deletable(false)
->label('Attachments')
]);
}
It works, but it's not graphically pleasing. I tried with Infolist (even if the best way, I think, is to use a table to show the attachments in a table), but I cannot use the SpatieMediaLibraryFileUpload inside this method. Is there a way to show a graphically pleasant list of all the attached files and allow the user to download them? Thanks a lot!
4 Replies
Sísifo
Sísifo8mo ago
Hi, I don't have answer for your question... maybe with a livewire component... however I am trying to have a Media RelationManager in a ItemResource... because Item can have several medias... and I get an error... I use exactly your code: "'class MediaRelationManager extends RelationManager { protected static string $relationship = 'media'; public function form(Form $form): Form { return $form ->schema([ SpatieMediaLibraryFileUpload::make('attachments') ->multiple() ->downloadable() ->columnSpanFull() ->deletable(false) ->label('Attachments') ]); }'" however I get that error:
Sísifo
Sísifo8mo ago
No description
Sísifo
Sísifo8mo ago
Any help?
Karthick K
Karthick K8mo ago
the spatie package table doesn't match with your table. Can you confirm you have another model in the name of Media which is not created by spatie library

Did you find this page helpful?