Filtered Data
I want to export only filtered table data to a csv , For instance, 10 records are in the database, and after using the filter only 3 reflect in the table, now I want these 3 records to be exported and generate a Csv. or is there any way with bulk actions by selecting them?
3 Replies
each()
over the list.Tables\Actions\BulkAction::make('export')
->action(function (Collection $records) {
$records = Prospect::where('interested', '=', 1)->get();
// Export the selected records to a CSV file
$records->each(function (Prospect $record) {
$record->export();
dd($record);
});
}),
like this @DrByte
Actually, don't need to call
each()
Here's an exporter I use with the Laravel-Excel package installed:
Bulk Action Button:
List page header Action Button, to export everything:
(I've also added label() and visible() and icon() etc, but you can do what you like)
And the actual Exporter: