Preface
Introduction
Data Grid Laravel is a data grid addon that provides an integration for the Laravel framework.
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.
Have a read through the Installation Guide and on how to Integrate it with Laravel 6.
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-laravel": "^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.
Integration
After installing the package, open your Laravel 7 config file which is located at config/app.php
and add the following lines.
In the $providers
array add the following service provider for this package.
Cartalyst\DataGrid\Laravel\DataGridServiceProvider::class,
In the $aliases
array add the following facade for this package.
'DataGrid' => Cartalyst\DataGrid\Laravel\Facades\DataGrid::class,
Configuration
After installing, you can publish the package configuration file into your application by running the following command on your terminal:
php artisan vendor:publish --tag="cartalyst:data-grid.config"
This will publish the config file to config/cartalyst/data-grid/config.php
where you can modify the package configuration.
Usage
In this section we'll show how you can make use of the extensions package.
Example
$object = new StdClass;
$object->title = 'foo';
$object->age = 20;
$data = [
[
'title' => 'bar',
'age' => 34,
],
$object,
];
$settings = [
'columns' => [
'title',
'age',
]
];
$handler = new CollectionHandler($data, $settings);
$dataGrid = DataGrid::make($handler);