Download the PHP package filamentphp/advanced-export without Composer
On this page you can find all versions of the php package filamentphp/advanced-export. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download filamentphp/advanced-export
More information about filamentphp/advanced-export
Files in filamentphp/advanced-export
Package advanced-export
Short Description Advanced export functionality for Filament resources with dynamic column selection, filtering, ordering, and background processing.
License MIT
Homepage https://github.com/filamentphp/advanced-export
Informations about the package advanced-export
Filament Advanced Export
Advanced export functionality for Filament resources with dynamic column selection, filtering, ordering, and background processing.
Features
- One-Command Setup - Configure export for any resource with a single command
- Dynamic Column Selection - Users choose which columns to export
- Custom Column Titles - Rename columns in the exported file
- XLSX and CSV Formats - Export in Excel or CSV format via modal selector
- Record Count Preview - See how many records will be exported before exporting
- Configurable Ordering - Sort by any column with validated input (ascending or descending)
- Automatic Filter Support - Automatically respects active Filament table filters
- Configurable Fallback Filters - Override fallback filter names per resource or via config
- Background Processing - Queue large exports for async processing
- Secure Error Handling - Generic user notifications, detailed internal logging
- View-Based Templates - Customizable Blade views for export formatting
- FilamentShield Integration - Per-resource export permissions (Export:Titular, etc.)
- Bilingual Support - English and Portuguese translations included
- Artisan Commands - Generate views and model methods automatically
Requirements
- PHP 8.2+
- Laravel 11.0+, 12.0+ or 13.0+
- Filament 4.0+ or 5.0+
- Maatwebsite Excel 3.1+ or 4.0+
Installation
Install the package via Composer:
Run the installation command:
This will:
- Publish the configuration file
- Publish translation files
- Register the plugin in your panel (interactive)
Manual Configuration
If you prefer manual setup, publish assets individually:
Quick Start
Option 1: One-Command Setup (Recommended)
The fastest way to add export functionality to any Filament resource:
This single command will:
- Configure the Model - Add
Exportableinterface, trait, and export methods - Generate Views - Create both simple and advanced export Blade templates
- Update ListRecords - Add the
HasAdvancedExporttrait and export action
That's it! Your resource now has full export functionality.
Options
Option 2: Step-by-Step Setup
If you prefer more control, you can set up each component individually:
1. Configure the Model
Or manually add the interface and methods:
2. Generate Export Views
This creates:
resources/views/exports/clientes-excel.blade.php(simple export)resources/views/exports/clientes-excel-advanced.blade.php(advanced export)
3. Add Trait to ListRecords
Automatic Filter Support
One of the key features of this package is automatic filter support. When users apply filters to your Filament table (e.g., ?filters[status][values][0]=pending), the export will automatically respect those filters.
How It Works
The package automatically:
- Extracts all active filters from the Filament table
- Checks if the filter column exists in the database table
- Applies the appropriate
WHEREorWHERE INclause
Supported Filter Types
| Filter Type | Example URL | Query Applied |
|---|---|---|
| Single value | ?filters[status][value]=active |
WHERE status = 'active' |
| Multiple values | ?filters[status][values][0]=pending&filters[status][values][1]=active |
WHERE status IN ('pending', 'active') |
| Date range | ?filters[created_at][from]=2024-01-01&filters[created_at][until]=2024-12-31 |
WHERE created_at BETWEEN ... |
Custom Filter Handling
For complex filters that don't map directly to columns, override the applyCustomFilter method:
Configuration
The configuration file is published to config/advanced-export.php:
CSV Export
The export modal includes a format selector. Users can choose between XLSX and CSV:
CSV exports use the CsvExport class which implements FromCollection and WithHeadings for clean tabular output without view templates.
Record Count Preview
The export modal shows how many records will be exported before the user clicks the export button. This count respects active filters and the configured maximum limit.
Fallback Filter Configuration
When dynamic filter extraction fails (e.g., non-standard table implementations), the package falls back to a configurable list of filter names:
You can also override per-resource:
Security
Error Handling
Export errors show a generic message to the user and log the full error internally:
- User sees: "An error occurred while processing the export. Please try again or contact support."
- Logs contain: Full exception message, stack trace, and context
Input Validation
- Order column is validated against the database schema and export columns list
- Order direction only accepts
ascordesc(case-insensitive), invalid values fall back todesc - Dot notation columns (e.g.,
client.name) are skipped gracefully in ordering -- overrideapplyCustomOrdering()to handle them with joins
Screenshots
Export Modal
Advanced Usage
Relationship Columns
You can export relationship data simply by using the relationship name as the column key:
The package will automatically detect and load the relationship, displaying the related model's default display value.
For more specific relationship data (like a specific attribute), use dot notation:
Eager Loading Relationships
To optimize performance, specify relationships to eager load:
Custom Ordering
The package validates order columns and directions automatically. Dot notation columns (relationship paths) are skipped by default.
To handle ordering by relationship columns, override applyCustomOrdering():
Using Package Default Views
If you don't want to create custom views for each model:
Artisan Commands
export:resource (Recommended)
Complete setup for a Filament resource in one command:
This command:
- Detects the model from the resource's
$modelproperty - Finds the ListRecords page from
getPages() - Runs
export:modelto configure the model - Runs
export:viewsto generate Blade templates - Updates the ListRecords page with the trait and action
export:install
Initial package setup:
export:model
Add export methods to a model:
export:views
Generate export views for a model:
export:publish
Publish package assets:
Translations
The package includes translations for:
- English (
en) - Portuguese (
pt)
To add more languages, publish the translations and create new language files:
Then create resources/lang/vendor/advanced-export/{locale}/messages.php.
Background Processing with Notifications
The package includes a powerful background export feature with automatic database notifications. This is ideal for large exports that would otherwise timeout.
Using Background Export Action
Add the background export action to your ListRecords page:
How It Works
- User clicks "Background Export" button
- A confirmation modal appears
- Upon confirmation,
ProcessExportJobis dispatched to the queue - User sees a notification that the export is being processed
- When complete, a database notification appears with a download link
- If the export fails, a failure notification is sent
Requirements for Database Notifications
Make sure your Filament panel has database notifications enabled:
Running the Queue Workers
Background exports require queue workers. Run both the exports queue and the default queue (for notifications):
Or use a single worker for both:
Dispatching Exports Programmatically
You can also dispatch exports directly:
Configuring the User Model
If you use a custom user model, configure it in config/advanced-export.php:
Filter Support in Background Exports
Background exports fully support all filter types:
| Filter Type | Automatically Handled |
|---|---|
| Direct columns | status, type |
| Relationship filters | insurer → insurer_id |
| Date ranges | created_at[from/until] |
| Multiple values | status[values][0,1,2] |
The ProcessExportJob automatically resolves relationship filter names to their actual column names (e.g., insurer → insurer_id).
Customizing Blade Views
The package uses Blade views to render Excel exports. You can customize these views to format data, add styling, or handle special fields.
View Types
| Type | Generated File | Purpose |
|---|---|---|
| Simple | {table}-excel.blade.php |
Exports all model attributes automatically |
| Advanced | {table}-excel-advanced.blade.php |
Exports only user-selected columns with custom titles |
View Variables
Both views receive these variables:
| Variable | Type | Description |
|---|---|---|
${tableName} |
Collection | The records to export (e.g., $declarations) |
$columnsConfig |
array | User-selected columns with titles (advanced only) |
Basic View Structure
Custom Field Formatting
Use @switch statements to format specific fields:
Complete Custom View Example
Here's a full example for a declarations export:
Using Package Default Views
If you don't need custom formatting, enable the package's default views:
The default views automatically:
- Format dates using
config('advanced-export.date_format') - Handle null values with
- - Convert booleans to Yes/No
- Serialize arrays/objects to JSON
Styling Excel Output
Maatwebsite Excel supports basic HTML styling:
Customizing the Export Button
Override trait methods to customize appearance:
FilamentShield Integration
If you use FilamentShield, the export button can be controlled per role/resource.
Step 1: Add the trait to your Resource
This registers export as a permission prefix. When you run php artisan shield:generate, Shield will create Export:Titular automatically.
Step 2: That's it!
The export button will only be visible to users with the Export:{Resource} permission. Without Shield installed, the button is visible to everyone.
How it works
HasExportPermissiontrait on the Resource → tells Shield to generate theexportpermissionHasAdvancedExporttrait on the ListRecords → checks if user has the permission before showing the button- Without Shield → export is always allowed (no breaking changes)
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Contributions are welcome! Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Credits
- Anselmo Kossa
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of advanced-export with dependencies
filament/filament Version ^4.0|^5.0
illuminate/contracts Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
maatwebsite/excel Version ^3.1|^4.0
spatie/laravel-package-tools Version ^1.16