https://github.com/allanvb/nova-exports
Package that allow you to export Laravel Nova resources.
https://github.com/allanvb/nova-exports
excel export-excel laravel nova
Last synced: 5 months ago
JSON representation
Package that allow you to export Laravel Nova resources.
- Host: GitHub
- URL: https://github.com/allanvb/nova-exports
- Owner: allanvb
- License: mit
- Created: 2021-04-14T09:48:14.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-06T02:58:51.000Z (almost 3 years ago)
- Last Synced: 2025-08-20T10:35:21.909Z (10 months ago)
- Topics: excel, export-excel, laravel, nova
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 2
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Laravel Nova package to export resources
This package adds and universal export action to your nova application.
## Requirements
- `laravel/nova: ^3.0`
- `gobrightspot/nova-detached-actions: ^1.1`
- `optimistdigital/nova-multiselect-field: ^2.0`
- `kpolicar/nova-date-range: dev-master`
- `rap2hpoutre/fast-excel: ^2.5`
## Usage
To use the export action, you must add it to `actions` method of your resource.
```php
use Allanvb\NovaExports\ExportResourceAction;
public function actions(Request $request): array
{
return [
new ExportResourceAction($this),
];
}
```
#### Available methods
- `only(array $columns)` - Define whitelist of fields that can be exported.
- `except(array $columns)` - Excludes the given fields from exporting list.
- `filename(string $name)` - Sets the download filename.
- `withUserSelection()` - Enables multi-select field that allow user to select the columns when exporting.
- `usesDateRange(string $columnName)` - Enables field that allow user to select the range of dates when exporting. *Default: `created_at`*
- `usesGenerator()` - Enables cursor usage when getting data from database.
- `queryBuilder(callable $query)` - Use own query on data exportation.
- `disk(string $disk)` - The storage you want to use for storing export files.
*`withUserSelection` method cannot be used together with `queryBuilder` method.*
You are also able to use all of [Nova Action](https://nova.laravel.com/docs/3.0/actions/defining-actions.html) methods, and all of [Detached Actions](https://github.com/gobrightspot/nova-detached-actions#display-on-different-screens) methods on `ExportResourceAction`.
## Exceptions
The package can throw the following exceptions:
| Exception | Reason |
| ------------------------------- | ------------------------------------------ |
| *ColumnNotFoundException* | Column does not exist in given table. |
| *EmptyDataException* | No records to export. |
| *RangeColumnNotDateException* | Given column for date range is not a date. |
## To do
- [x] Export single resource
- [x] Implement user selection export
- [x] Implement generator on exporting
- [x] Add way to perform joins on export
- [ ] Add Eloquent relations export
- [ ] Add option to export to PDF
## License
The MIT License (MIT). Please see [License File](LICENCE) for more information.