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
Expecto PatronumOP7mo ago
Anyone can help?
abdullafahem
abdullafahem7mo ago
If I understand you need to export all collection in one pdf right?
Expecto Patronum
Expecto PatronumOP7mo ago
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
abdullafahem7mo ago
Why you are not using the ExportAction from Filament itself?
Expecto Patronum
Expecto PatronumOP7mo ago
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
abdullafahem7mo 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
Vp7mo 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
abdullafahem7mo ago
Same as you was in beginning, but is "Relation Manager"
Vp
Vp7mo 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
Expecto PatronumOP7mo ago
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
Vp7mo 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
Expecto PatronumOP7mo ago
Havent yet . I will try . Get back to you later
Want results from more Discord servers?
Add your server