Preface
Introduction
Data Grid Export is a Data Grid Addon that adds support to export various formats to data grid.
We currently have the following export drivers:
- CSV Driver
- JSON Driver
- PDF Driver
The package requires PHP 7.2.5+ and follows the FIG standard PSR-4 to ensure a high level of interoperability between shared PHP code and is fully unit-tested.
Setup
Installation
Cartalyst packages utilize Composer, for more information on how to install Composer please read the Composer Documentation.
Preparation
Open your composer.json
file and add the following to the require
array:
"cartalyst/data-grid-export": "^3.0"
Add the following lines after the require
array on your composer.json
file:
"repositories": [
{ "type": "composer", "url": "https://packages.cartalyst.com" }
]
Note: Make sure that after the required changes your
composer.json
file is valid by runningcomposer validate
.
Install the dependencies
Run the composer install
or composer update
to install or update the new requirement.
Usage
To add export support to any data grid, just instantiate an export provider and pass it as the last argument to the data grid call.
$dataSource = ...
$columns = [
'id',
'name',
'created_at',
];
$sorts = [
'column' => 'created_at',
'direction' => 'desc',
];
$settings = compact('columns');
$provider = new ExportProvider();
return datagrid($dataSource, $settings, $provider);