gevorgmelkumyan / nova-csv-export
dev-master
2021-11-19 21:28 UTC
Requires
- php: >=7.3
Requires (Dev)
- laravel/framework: >=6.0
- laravel/nova: ~3.0
This package is auto-updated.
Last update: 2025-04-20 04:43:07 UTC
README
This package allows you to export resources as a csv file.
Prerequisites
- php >= 7.3
- Laravel >= 6.0
- Laravel Nova ~3.0
Installation
composer require gevorgmelkumyan/nova-csv-export
Usage
- Make the model of the resource you desire to export to use
Exportable
trait:
namespace App\Models; use GevorgMelkumyan\Models\Exportable; class User extends Authenticable { use Exportable; }
- Inside the model override
mapping
array fetched fromExportable
by specifying model's attributes as keys and their labels as the values:
... protected $mapping = [ 'id' => 'ID', 'first_name' => 'First Name', 'dob' => 'Date Of Birth', ]; ...
- Inside the resource related to the model add
ExportCsv
toActions
specifying the directory where the csv files will be stored:
use GevorgMelkumyan\Actions\ExportCsv; ... public function actions() { return [ new ExportCsv('csv'), ]; }