Show file uploaded in Infolist

Hi. My forms uploads a PDF to the storage. Is there a way to show a component in an Infolist and download the file? Thanks
8 Replies
neverything
neverything4mo ago
I would probably do it with a custom entry, you will get access to the record and can use the Laravel storage helpers for download buttons and such: https://filamentphp.com/docs/3.x/infolists/entries/custom
Dennis Koch
Dennis Koch4mo ago
Simplest for is probably a TextEntry with a ->url()
juin.lima
juin.lima3mo ago
But what if it is an array with multiple attachments? I tried but I couldn't.
Dennis Koch
Dennis Koch3mo ago
If it's an array, you can use a callback that get's passed the state: ->url(fn ($state) => )
juin.lima
juin.lima3mo ago
Exactly, that's what I tried. TextEntry::make('attachment') ->url(fn ($state) => url('storage/'.$state)) ->listWithLineBreaks(), ErrorException Array to string conversion I also tried like this TextEntry::make('attachments') ->url(function ($state) { foreach ($state as $attachment) { return url('storage/'.$attachment); } }) ->listWithLineBreaks(), But it always shows only the first attachment.
Dennis Koch
Dennis Koch3mo ago
->url() might not support array then, sorry.
Solution
juin.lima
juin.lima3mo ago
Oops, I managed to solve it using Custom entries. https://filamentphp.com/docs/3.x/infolists/entries/custom My view: <x-dynamic-component :component="$getEntryWrapperView()" :entry="$entry"> <div> @foreach($getState() as $state) <p><a href="{{ url('storage/'.$state) }}" title="Download">{{ $state }}</a></p> @endforeach </div> </x-dynamic-component>
Want results from more Discord servers?
Add your server