Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Filament Action Export Laravel Package

jeffersongoncalves/filament-action-export

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require jeffersongoncalves/filament-action-export
    

    Publish the config (optional):

    php artisan vendor:publish --provider="JeffersonGoncalves\FilamentActionExport\FilamentActionExportServiceProvider"
    
  2. 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'
            ]);
    }
    
  3. Where to Look First

    • README.md for basic usage.
    • config/filament-action-export.php for configuration options.
    • src/Actions/ExportAction.php for customization hooks.

Implementation Patterns

Common Workflows

  1. Basic Export

    ExportAction::make()
        ->label('Download CSV')
        ->format('csv')
        ->filename('users-export-' . now()->format('Y-m-d'))
    
  2. Conditional Export

    ExportAction::make()
        ->label('Export Active Users')
        ->format('xlsx')
        ->query(fn (Builder $query) => $query->where('active', true))
    
  3. 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'),
        ])
    
  4. Integration with Filament Panels

    public static function getPages(): array
    {
        return [
            Tables\UsersTable::class,
        ];
    }
    

Advanced Patterns

  1. Dynamic Filename

    ExportAction::make()
        ->filename(fn () => 'export-' . now()->timestamp . '.csv')
    
  2. Custom Headers/Footers (PDF)

    ExportAction::make()
        ->format('pdf')
        ->pdfOptions([
            'header' => view('filament.export-header'),
            'footer' => view('filament.export-footer'),
        ])
    
  3. Event Listeners for Post-Export Logic

    ExportAction::make()
        ->listeners([
            fn () => Log::info('Export triggered for ' . auth()->id()),
        ])
    
  4. 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))),
        ]),
    ])
    

Gotchas and Tips

Pitfalls

  1. Memory Limits

    • Large exports (e.g., 100K+ rows) may hit PHP memory limits. Use chunking:
      ExportAction::make()
          ->chunkSize(1000)
      
  2. PDF Rendering Issues

    • Ensure dompdf or barryvdh/laravel-dompdf is installed for PDF exports:
      composer require barryvdh/laravel-dompdf
      
  3. Column Visibility

    • Hidden columns in the table may still export unless explicitly excluded:
      ExportAction::make()
          ->excludeHiddenColumns()
      
  4. CSRF Token Mismatch

    • If using Filament’s built-in auth, ensure the export action is registered in a resource/page, not a standalone route.

Debugging

  1. Check Export Logs

    • Enable debug mode in config/filament-action-export.php:
      'debug' => env('FILAMENT_EXPORT_DEBUG', false),
      
    • Logs will appear in storage/logs/filament-export.log.
  2. Validate Formats

    • Verify supported formats (csv, xlsx, pdf) are enabled in config:
      'formats' => ['csv', 'xlsx', 'pdf'],
      
  3. Test with Small Datasets

    • Start with a small subset of data to validate the export logic before scaling.

Tips

  1. Custom Styling (PDF/XLSX)

    • Override default styles via config:
      'pdf' => [
          'font' => 'Arial',
          'font_size' => 10,
          'margin_top' => 20,
      ],
      
  2. Localization

    • Translate labels and messages:
      ExportAction::make()
          ->label(__('filament-export::actions.export'))
      
  3. Performance Optimization

    • Use ->withoutEvents() for non-critical exports to skip event firing:
      ExportAction::make()
          ->withoutEvents()
      
  4. Extension Points

    • Extend the action class for custom logic:
      class CustomExportAction extends ExportAction
      {
          public function getFilename(): string
          {
              return 'custom-' . parent::getFilename();
          }
      }
      
  5. Preview Mode

    • Enable preview for PDF/Excel before download:
      ExportAction::make()
          ->enablePreview()
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium