Buttons Configurations
Artisan Console Configurations
Namespace configuration is used by the datatables command generator:
<?php return [ 'namespace' => [ 'base' => 'DataTables', 'model' => '', ],];
DataTable Base Namespace/Directory
This is the base namespace/directory to be created when a new DataTable is called. This directory is appended to the default Laravel namespace.
Usage:
php artisan datatables:make User
Output: App\DataTables\UserDataTable
Export filename: users_(timestamp)
Model Option
This is the base namespace/directory where your models are located:
Usage:
php artisan datatables:make Post --model
Output: App\DataTables\PostDataTable
With Model: App\Post
Export filename: posts_(timestamp)
PDF Generator
Set the PDF generator to be used when converting your DataTable to PDF:
'pdf_generator' => 'excel', // or 'snappy'
Available generators are: excel, snappy
Excel Generator
When excel is used as the generator, the package will use maatwebsite/excel to generate the PDF.
[!NOTE] To export files to PDF, you will have to include
dompdf/dompdf,mpdf/mpdf, ortecnick.com/tcpdfin yourcomposer.jsonand change theexport.pdf.driverconfig setting accordingly.
Snappy Generator
When snappy is used as the generator, you need to install barryvdh/laravel-snappy:
composer require barryvdh/laravel-snappy
Snappy PDF Options
These are the options passed to laravel-snappy when exporting the PDF file:
<?php return [ 'snappy' => [ 'options' => [ 'no-outline' => true, 'margin-left' => '0', 'margin-right' => '0', 'margin-top' => '10mm', 'margin-bottom' => '10mm', ], 'orientation' => 'landscape', ], /* * Default html builder parameters. */ 'parameters' => [ 'dom' => 'Bfrtip', 'order' => [[0, 'desc']], 'buttons' => [ 'excel', 'csv', 'pdf', 'print', 'reset', 'reload', ], ], /* * Generator command default options. */ 'generator' => [ 'columns' => 'id,add your columns,created_at,updated_at', 'buttons' => 'excel,csv,pdf,print,reset,reload', 'dom' => 'Bfrtip', ],];
Default Builder Parameters
The parameters config sets default DataTables HTML builder options:
'parameters' => [ 'dom' => 'Bfrtip', 'order' => [[0, 'desc']], 'buttons' => [ 'excel', 'csv', 'pdf', 'print', 'reset', 'reload', ],],
dom: DataTables layout structureorder: Default column orderingbuttons: Default buttons to display
Generator Options
The generator config sets default options for the datatables:make command:
'generator' => [ 'columns' => 'id,add your columns,created_at,updated_at', 'buttons' => 'excel,csv,pdf,print,reset,reload', 'dom' => 'Bfrtip',],
See Also
- Buttons Installation - Setup the buttons package
- Buttons Export - Export button options
- Buttons Custom - Custom button actions