RepeatableEntry relationship

Hello, I have a infolist code
RepeatableEntry::make('attachments')
->schema([
TextEntry::make('file')
->action(Action::make('download_file')->action(function () {
??? return Storage::download(path);
})),
])->columns(12)->columnSpan(4),
RepeatableEntry::make('attachments')
->schema([
TextEntry::make('file')
->action(Action::make('download_file')->action(function () {
??? return Storage::download(path);
})),
])->columns(12)->columnSpan(4),
I would like to make it download a file when clicked but I can't get to the file. I can get Job model in function but in Job model I have a attachments relation where I have all attachment files. How can I get to just this one file and not all of them?
Solution:
@__Dementor Injecting $record inside the action's callback should give you access to the related attachment model. I just used RepeatableEntry in exactly this way in one of my Filament apps. ```php RepeatableEntry::make('attachments') ->schema([...
Jump to solution
2 Replies
Matthew
Matthew2mo ago
I find best way to do anything like that is to use a table widget and a blade view in your infolist instead of the repeatable entries.
Solution
tg
tg2mo ago
@__Dementor Injecting $record inside the action's callback should give you access to the related attachment model. I just used RepeatableEntry in exactly this way in one of my Filament apps.
RepeatableEntry::make('attachments')
->schema([
TextEntry::make('file')
->action(
Action::make('download_file')
->action(fn (Attachment $record) => Storage::download($record->path))
),
]),
RepeatableEntry::make('attachments')
->schema([
TextEntry::make('file')
->action(
Action::make('download_file')
->action(fn (Attachment $record) => Storage::download($record->path))
),
]),

Did you find this page helpful?