jeffersongoncalves/filament-action-export
Installation
composer require jeffersongoncalves/filament-action-export
Publish the config (optional):
php artisan vendor:publish --provider="JeffersonGoncalves\FilamentActionExport\FilamentActionExportServiceProvider"
First Use Case Register the export action in your Filament table:
use JeffersonGoncalves\FilamentActionExport\Actions\ExportAction;
protected static string $exportActionName = 'export';
public static function table(Table $table): Table
{
return $table
->columns([
// your columns
])
->actions([
ExportAction::make()
->label('Export Data')
->format('csv') // or 'xlsx', 'pdf'
]);
}
Where to Look First
config/filament-action-export.php for configuration options.src/Actions/ExportAction.php for customization hooks.Basic Export
ExportAction::make()
->label('Download CSV')
->format('csv')
->filename('users-export-' . now()->format('Y-m-d'))
Conditional Export
ExportAction::make()
->label('Export Active Users')
->format('xlsx')
->query(fn (Builder $query) => $query->where('active', true))
Custom Columns
ExportAction::make()
->label('Custom Export')
->format('pdf')
->columns([
Tables\Columns\TextColumn::make('name')->label('Full Name'),
Tables\Columns\TextColumn::make('email')->label('User Email'),
])
Integration with Filament Panels
public static function getPages(): array
{
return [
Tables\UsersTable::class,
];
}
Dynamic Filename
ExportAction::make()
->filename(fn () => 'export-' . now()->timestamp . '.csv')
Custom Headers/Footers (PDF)
ExportAction::make()
->format('pdf')
->pdfOptions([
'header' => view('filament.export-header'),
'footer' => view('filament.export-footer'),
])
Event Listeners for Post-Export Logic
ExportAction::make()
->listeners([
fn () => Log::info('Export triggered for ' . auth()->id()),
])
Bulk Export from Table Actions
->actions([
Tables\Actions\BulkActionGroup::make([
ExportAction::make()
->label('Export Selected')
->format('csv')
->query(fn (Builder $query) => $query->whereIn('id', fn ($query) => $query->getSelected($this))),
]),
])
Memory Limits
ExportAction::make()
->chunkSize(1000)
PDF Rendering Issues
dompdf or barryvdh/laravel-dompdf is installed for PDF exports:
composer require barryvdh/laravel-dompdf
Column Visibility
ExportAction::make()
->excludeHiddenColumns()
CSRF Token Mismatch
Check Export Logs
config/filament-action-export.php:
'debug' => env('FILAMENT_EXPORT_DEBUG', false),
storage/logs/filament-export.log.Validate Formats
csv, xlsx, pdf) are enabled in config:
'formats' => ['csv', 'xlsx', 'pdf'],
Test with Small Datasets
Custom Styling (PDF/XLSX)
'pdf' => [
'font' => 'Arial',
'font_size' => 10,
'margin_top' => 20,
],
Localization
ExportAction::make()
->label(__('filament-export::actions.export'))
Performance Optimization
->withoutEvents() for non-critical exports to skip event firing:
ExportAction::make()
->withoutEvents()
Extension Points
class CustomExportAction extends ExportAction
{
public function getFilename(): string
{
return 'custom-' . parent::getFilename();
}
}
Preview Mode
ExportAction::make()
->enablePreview()
How can I help you explore Laravel packages today?