cswni/filament-export
Composer 安装命令:
composer require cswni/filament-export
包简介
Customizable export and print functionality for Filament Admin Panel
README 文档
README
Customizable export and print functionality for Filament Admin Panel.
This package provides a bulk action and header action to export your filament tables easily.
Requirements
- PHP 8
- Filament 2.0
Dependencies
Installation
composer require cswni/filament-export
Using
Simple Usage
Bulk Action
You can export selected rows with the bulk action.
$table->bulkActions([ ... FilamentExportBulkAction::make('export') ... ]);
Header Action
You can filter, search, sort and export your table with the header action.
$table->headerActions([ ... FilamentExportHeaderAction::make('export') ... ]);
Since ButtonAction is deprecated you may use this action with ->button() instead.
Full Usage
Both actions provide functions for configuration.
FilamentExportBulkAction::make('export') ->fileName('My File') // Default file name ->timeFormat('m y d') // Default time format for naming exports ->defaultFormat('pdf') // xlsx, csv or pdf ->defaultPageOrientation('landscape') // Page orientation for pdf files. portrait or landscape ->directDownload() // Download directly without showing modal ->disableAdditionalColumns() // Disable additional columns input ->disableFilterColumns() // Disable filter columns input ->disableFileName() // Disable file name input ->disableFileNamePrefix() // Disable file name prefix ->disablePreview() // Disable export preview ->withHiddenColumns() //Show the columns which are toggled hidden ->fileNameFieldLabel('File Name') // Label for file name input ->formatFieldLabel('Format') // Label for format input ->pageOrientationFieldLabel('Page Orientation') // Label for page orientation input ->filterColumnsFieldLabel('filter columns') // Label for filter columns input ->additionalColumnsFieldLabel('Additional Columns') // Label for additional columns input ->additionalColumnsTitleFieldLabel('Title') // Label for additional columns' title input ->additionalColumnsDefaultValueFieldLabel('Default Value') // Label for additional columns' default value input ->additionalColumnsAddButtonLabel('Add Column') // Label for additional columns' add button
You can also use default bulk action and header action functions to customize actions.
Performance Tips for Large Datasets
- Since header action does server-side pagination you may choose header action over bulk action.
- You may disable preview.
- You may enable direct download.
Configuration
Publish configuration
php artisan vendor:publish --provider="AlperenErsoy\FilamentExport\FilamentExportServiceProvider" --tag="config"
You can configure these settings:
return [ 'default_format' => 'xlsx', 'time_format' => 'M_d_Y-H_i', 'default_page_orientation' => 'portrait', 'disable_additional_columns' => false, 'disable_filter_columns' => false, 'disable_file_name' => false, 'disable_preview' => false, 'use_snappy' => false, 'action_icon' => 'heroicon-o-document-download', 'preview_icon' => 'heroicon-o-eye', 'export_icon' => 'heroicon-o-download', 'print_icon' => 'heroicon-o-printer', 'cancel_icon' => 'heroicon-o-x-circle' ];
Overriding Views
Publish views
php artisan vendor:publish --provider="AlperenErsoy\FilamentExport\FilamentExportServiceProvider" --tag="views"
This package has two views:
-
"components\table_view.blade.php" view is used for preview.
-
"pdf.blade.php" view is used as pdf export template.
-
"print.blade.php" view is used as print template.
Using Custom Variables In Templates
FilamentExportBulkAction::make('export') ->extraViewData([ 'myVariable' => 'My Variable' ])
or use closures
FilamentExportHeaderAction::make('export') ->extraViewData(fn ($action) => [ 'recordCount' => $action->getRecords()->count() ])
Then use them in the templates as regular blade variables:
{{ $myVariable }}
Using Snappy
By default, this package uses dompdf as pdf generator.
If you want to use Snappy instead you need to install barryvdh/laravel-snappy to your project and configure it yourself. (See barryvdh/laravel-snappy for more information.)
To use snappy for PDF exports:
- You can simply add ->snappy() to your actions.
FilamentExportBulkAction::make('export') ->snappy()
or
FilamentExportHeaderAction::make('export') ->snappy()
- You can update the config file to use it as default.
[
...
'use_snappy' => true,
...
]
cswni/filament-export 适用场景与选型建议
cswni/filament-export 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 230 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cswni/filament-export 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cswni/filament-export 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 230
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-01-13
