alperenersoy / filament-export

Customizable export and print functionality for Filament Admin Panel
211 stars 49 forks source link

Column formatting #114

Closed shopapps closed 11 months ago

shopapps commented 11 months ago

Added ability to format the column data before exporting CSV.

new method ->formatColumns() on the FilamentExportHeaderAction

can be passed any array of column names or mix of column names and closures.

if just a column name is passed the raw value is exported.

Example usage

FilamentExportHeaderAction::make('export')->label(__('Export'))
                    ->formatColumns([
                        'status', // will just return raw value
                        'numbers' => fn(Customer $record): string => $record->numbers()->where('status', Number::STATUS_ACTIVE)->count() . ' / ' . $record->numbers()->where('status', Number::STATUS_DISABLED)->count(),
                    ])
alperenersoy commented 11 months ago

Fixes https://github.com/alperenersoy/filament-export/issues/113