Multiple Model Export Action
What I am trying to do:
Trying to create a custom export action in v4. From a single button, I want a trigger that will call multiple separate exporters (and therefore multiple CSV files exported). Essentially a streamlined way to export an entire database.
What I did:
Tried to make an action, with two exporters as that action. Clicking the button doesn’t appear to trigger the exporter. I’ve also tried extending the default exporter classes but still couldn’t figure it out. I fear this is incredibly simple but I’m too far into the woods. I’m not very comfortable with actions and classes, any help or suggestions would be appreciated.
Code:
```php
Action::make('Export Projects')
->action(function () {
ExportAction::make('export_projects')
->columnMapping(false)
->exporter(ProjectExporter::class);
ExportAction::make('export_subcomponents')
->columnMapping(false)
->exporter(SubcomponentExporter::class);
});
```
2 Replies
You can't just nest an Action inside an Action. That's why it's not doing anything.
I guess you need to look into how
ExportAction
works and see whether you can extend this to multiple Exporters. I guess you're better off, writing your own solution with an existing export library.Ah I was worried that would be the case. Thank you for the help