Generate PDF From Collection Relation Manager ( Step By Filament Daily)

hi all, i create action to export data from relation manager . im trying to follow step according what filament daily show in their website https://laraveldaily.com/post/filament-export-record-to-pdf-two-ways. my problem is . i wanted to generate pdf based on Collection without i need to tick one by one. it will get all collection record from my relation manager by default . how to do that ?
No description
No description
No description
13 Replies
Expecto Patronum
Anyone can help?
abdullafahem
abdullafahem2mo ago
If I understand you need to export all collection in one pdf right?
Expecto Patronum
Yes Its working But the problem is i need to select first in order to let the data in pdf to be generated I want to let all the data in relation manager will generate without i need to select
abdullafahem
abdullafahem2mo ago
Why you are not using the ExportAction from Filament itself?
Expecto Patronum
Because first i want to generate in pdf Second, i need to use custom design for the report table Do you have an idea to let convert in pdf and use custom view by using export action?
abdullafahem
abdullafahem2mo ago
In this situation I don't think that let you to customize the template, but you can use another libraries such as Laravel Excel https://docs.laravel-excel.com/3.1/exports/
🚀 5 minute quick start | Laravel Excel
Supercharged Excel exports and imports in Laravel
Vp
Vp2mo ago
I think your ->action() will still work using Action (header action in listResource) but need to tweak a little bit oh wait, didn't see "relation manager"..
abdullafahem
abdullafahem2mo ago
Same as you was in beginning, but is "Relation Manager"
Vp
Vp2mo ago
Can you try like this:
->headerActions([
Tables\Actions\Action::make('download')
->action(function (Application $app) { // called the model directly
dd($app->get());
// download pdf
}),
])
->headerActions([
Tables\Actions\Action::make('download')
->action(function (Application $app) { // called the model directly
dd($app->get());
// download pdf
}),
])
And you can use $this->getOwnerRecord()->getKey() to get the parent id for filter
Expecto Patronum
To generate is working as long as i select the id and run the action . I just wondering how to generate without i need to select . Its like auto capture all the data in relation manager by default when generating
Vp
Vp2mo ago
Did you try my action example? all you have to do is click the button and it will download if you configure correctly
Expecto Patronum
Havent yet . I will try . Get back to you later