kompreso / nero-backpack-export
Requires
- php: ^8.1
- anourvalar/eloquent-serialize: ^1.2
- backpack/crud: ^6.0
- phpoffice/phpspreadsheet: ^1.29
README
There is a problem with exporting data from pages in Backpack, it exports only the data that you see on page, and it's limited up to 100 rows.
So the main purpose of this package is to allow you to export not only data you see on page but all rows. Also, it works even if you have applied filters.
The export based on job. After the export (job) is done, it will send a letter to user's email. But if you want, you can override this logic and set your own Notification class, it can be done with changing config (backpack_export.php).
I recommend to check the config out, it can be found in config of your application (config/backpack_export.php)
Install
To install this package, you have to run this command:
composer require nero/backpack-export
Next step is to run:
php artisan vendor:publish --provider="Nero\BackpackExport\Application\ExportServiceProvider"
As result of command, there will be 2 files added in your application:
- in app/config, there will be
backpack_export.php
config - in your resource/views/vendor/backpack/crud/inc, there will be
export_buttons.blade.php
How to use
After installing you have to make 3 steps:
- Go to the crud class where you want to enable an export
- Include
Nero\BackpackExport\Application\Traits\ExportOperation
trait. Example:
use \Nero\BackpackExport\Application\Traits\ExportOperation;
- Go to the setupListOperation and call
enableAdvancedExportButtons
method:
protected function setupListOperation() { $this->enableAdvancedExportButtons(); // ... }
IMPORTANT: You MUST call either
$this->crud->enableExportButtons();
or$this->enableAdvancedExportButtons();
, but not both!
It's done!. Now you can export all data from table, not only the displayed ones
Uninstall
Uninstalling process is not complicated. It consists of two steps:
- removing package from composer
- removing config, views and language files
To remove package, execute this command
composer remove nero/backpack-export
Then we have to delete config. It can be found in config, full path config/backpack_export.php
:
rm config/backpack_export.php
Now we have to delete export_buttons.blade.php
. It can be found as resource/views/vendor/backpack/crud/inc/export_buttons.blade.php
:
rm resource/views/vendor/backpack/crud/inc/export_buttons.blade.php
As last step is deleting language packages:
rm resources/lang/en/backpack_export.php rm resources/lang/ru/backpack_export.php
TODO
- Write a better documentation
- Make PDF compatibility
- Improve handling custom_html columns
- Refactoring code
- Fix fetch in view (list.blade.php)
- Remove unnecessary code
- Convert date format in row ("Monday 11 December 2023 14:00:00") to application chosen format
- Agility to except any columns from export