### Install filament-action-export via Composer Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Install the package version 3.x, which is compatible with Filament 5.x and PHP ^8.2. ```bash composer require jeffersongoncalves/filament-action-export "^3.0" ``` -------------------------------- ### Use Snappy PDF driver Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Switch the PDF driver from the default barryvdh/laravel-dompdf to barryvdh/laravel-snappy. First install the package, then use snappy() or pdfDriver('snappy') and optionally set custom PDF options. ```bash composer require barryvdh/laravel-snappy ``` ```php // Use Snappy ->snappy() // Or set driver explicitly ->pdfDriver('snappy') // Custom PDF options ->pdfOptions(['paper' => 'a4', 'orientation' => 'landscape']) ``` -------------------------------- ### Custom format column values Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Custom formatting for column values. Each key is a column name and the value is a closure that receives the value and optionally the record. The example shows uppercasing, date formatting, and a match expression for status. ```php ->formatStates([ 'name' => fn ($value, $record) => strtoupper($value), 'created_at' => fn ($value) => Carbon::parse($value)->format('d/m/Y'), 'status' => fn ($value) => match ($value) { 'active' => 'Active', 'inactive' => 'Inactive', default => $value, }, ]) ``` -------------------------------- ### Enable direct download Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Skips the modal form and downloads the file immediately using the default settings. ```php ->directDownload() ``` -------------------------------- ### Publish views for filament-action-export Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Publish the package views. This step is optional. ```bash php artisan vendor:publish --tag=filament-action-export-views ``` -------------------------------- ### Publish config for filament-action-export Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Publish the package configuration file. This step is optional. ```bash php artisan vendor:publish --tag=filament-action-export-config ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Run the package test suite with Composer. ```bash composer test ``` -------------------------------- ### Configure filament-action-export via config/filament-action-export.php Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Global configuration for the Filament action export package. Set options like pdf_driver, default_format, formats, csv_delimiter, chunk_size, time_format, pdf_options, preview_enabled, print_enabled, use_snappy, and various disable_* flags. Also allows customizing icons for action, preview, export, print, and cancel. ```php // config/filament-action-export.php return [ 'pdf_driver' => env('FILAMENT_EXPORT_PDF_DRIVER', 'dompdf'), 'default_format' => env('FILAMENT_EXPORT_DEFAULT_FORMAT', 'xlsx'), 'formats' => ['csv', 'xlsx', 'pdf'], 'csv_delimiter' => ',', 'chunk_size' => 1000, 'time_format' => 'Y-m-d_H-i', 'pdf_options' => [ 'paper' => 'a4', 'orientation' => 'portrait', ], 'preview_enabled' => true, 'print_enabled' => true, 'use_snappy' => false, 'disable_additional_columns'=> false, 'disable_filter_columns' => false, 'disable_file_name' => false, 'disable_file_name_prefix' => false, 'disable_preview' => false, 'icons' => [ 'action' => 'heroicon-o-arrow-down-tray', 'preview' => 'heroicon-o-eye', 'export' => 'heroicon-o-arrow-down-tray', 'print' => 'heroicon-o-printer', 'cancel' => 'heroicon-o-x-circle', ], ]; ``` -------------------------------- ### Publish translations for filament-action-export Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Publish the package translation files. This step is optional. ```bash php artisan vendor:publish --tag=filament-action-export-translations ``` -------------------------------- ### Configure export formats and default format Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Sets the available export formats and the default format. The default format is used when the modal is not shown or when the user does not select a format. ```php ->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf]) ->defaultFormat(ExportFormat::Xlsx) ``` -------------------------------- ### Add FilamentExportHeaderAction to table header actions Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Adds an export action to the table's header actions, exporting all records while respecting active filters, search, and sort. Uses snappy for PDF generation and includes extra view data. ```php use JeffersonGoncalves\FilamentExportAction\Actions\FilamentExportHeaderAction; use JeffersonGoncalves\FilamentExportAction\Enums\ExportFormat; public function table(Table $table): Table { return $table ->columns([ TextColumn::make('name'), TextColumn::make('email'), ]) ->headerActions([ FilamentExportHeaderAction::make('export') ->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf]) ->defaultFormat(ExportFormat::Xlsx) ->withFilters() ->withSearch() ->withSort() ->snappy() ->extraViewData(['companyName' => 'Acme Corp']), ]); } ``` -------------------------------- ### Header action export options Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Options for header actions: apply active filters, search, and sort to the export, and modify the query before export. Multiple modifyQueryUsing calls stack. ```php // Apply active table filters to export ->withFilters() // Apply active search to export ->withSearch() // Apply active sort to export ->withSort() // Modify the query before export ->modifyQueryUsing(fn ($query) => $query->where('active', true)) // Multiple query modifications (they stack) ->modifyQueryUsing(fn ($query) => $query->where('active', true)) ->modifyQueryUsing(fn ($query) => $query->where('role', 'admin')) ``` -------------------------------- ### Disable preview and print Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Disables the preview in the modal and the print button. ```php // Disable preview in the modal ->disablePreview() // Disable print button ->disablePrint() ``` -------------------------------- ### Configure export columns Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Options to control which columns are exported: specify columns, exclude columns, add extra Filament Column objects, disable the column filter checkboxes, include hidden columns, or disable table columns entirely. ```php // Use specific columns ->columns(['id', 'name', 'email']) // Exclude columns ->excludeColumns(['password', 'remember_token']) // Add extra Filament Column objects ->withColumns([ TextColumn::make('full_address'), ]) // Disable the column filter checkboxes in the modal ->disableFilterColumns() // Include hidden (toggled) columns in the export ->withHiddenColumns() // Disable table columns entirely (use only additional columns) ->disableTableColumns() ``` -------------------------------- ### Add FilamentExportBulkAction to table bulk actions Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Adds an export action to the table's bulk actions, allowing users to export selected records. Configure formats, default format, excluded columns, additional columns, and extra view data. ```php use JeffersonGoncalves\FilamentExportAction\Actions\FilamentExportBulkAction; use JeffersonGoncalves\FilamentExportAction\Enums\ExportFormat; use JeffersonGoncalves\FilamentExportAction\ValueObjects\AdditionalColumn; public function table(Table $table): Table { return $table ->columns([ TextColumn::make('name'), TextColumn::make('email'), ]) ->bulkActions([ FilamentExportBulkAction::make('export') ->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf]) ->defaultFormat(ExportFormat::Xlsx) ->excludeColumns(['password', 'remember_token']) ->additionalColumns([ AdditionalColumn::make('exported_at') ->defaultValue(now()->format('d/m/Y')), ]) ->extraViewData(['companyName' => 'Acme Corp']), ]); } ``` -------------------------------- ### Set CSV delimiter Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Sets the CSV delimiter. The default is a comma. ```php ->csvDelimiter(';') // Default: ',' ``` -------------------------------- ### Add additional columns with user inputs Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Adds extra columns with user-fillable inputs in the export modal. Each column can have a label and a default value. Use disableAdditionalColumns() to turn them off. ```php ->additionalColumns([ AdditionalColumn::make('exported_at') ->label('Exported At') ->defaultValue(now()->format('d/m/Y')), AdditionalColumn::make('notes') ->label('Notes') ->defaultValue('N/A'), ]) // Disable additional columns ->disableAdditionalColumns() ``` -------------------------------- ### Customize export file name Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Options to customize the exported file name: set a custom name, add a prefix, disable the prefix, set a custom time format for the suffix, disable the file name input in the modal, or use a closure for full control. ```php // Custom file name ->fileName('my-report') // File name prefix (prepended to the name) ->fileNamePrefix('users') // Disable prefix ->disableFileNamePrefix() // Custom time format for the filename suffix ->timeFormat('d_m_Y-H_i') // Disable file name input in the modal ->disableFileName() // Full control via closure ->fileNameUsing(fn ($action) => 'custom-' . now()->format('Y-m-d')) ``` -------------------------------- ### Pass extra view data to templates Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Pass additional data to the PDF/print Blade templates. Can be a static array or a closure that receives the action and returns an array. ```php // Static array ->extraViewData(['companyName' => 'Acme Corp']) // Dynamic closure ->extraViewData(fn ($action) => [ 'recordCount' => $action->getRecords()->count(), ]) ``` -------------------------------- ### Set default PDF page orientation Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Sets the default page orientation for PDF exports. The default is 'portrait'. ```php // Set default page orientation for PDF export ->defaultPageOrientation('landscape') // Default: 'portrait' ``` -------------------------------- ### Modify Excel and PDF writers Source: https://github.com/jeffersongoncalves/filament-action-export/blob/3.x/README.md Customize the Excel or PDF writer before the file is generated. The Excel writer is a SimpleExcelWriter for CSV/XLSX; the PDF instance is DomPDF or Snappy. ```php // Modify the SimpleExcelWriter (CSV/XLSX) ->modifyExcelWriter(fn (SimpleExcelWriter $writer) => $writer) // Modify the PDF instance (DomPDF or Snappy) ->modifyPdfWriter(fn ($pdf) => $pdf->setWarnings(false)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.