Skip to content
Icon

WARNING You're browsing the documentation for an old version of LARAVEL-DATATABLES. Consider upgrading your project to laravel-datatables 11.0.

General Settings

Introduction

You can change the package behavior by updating the configuration file.

The configuration file can be found at config/datatables.php.

Smart Search

Smart search will enclose search keyword with wildcard string "%keyword%". The sql generated will be like column LIKE "%keyword%" when set to true.

'smart' => true,

Case Sensitive Search

Case insensitive will search the keyword in lower case format. The sql generated will be like LOWER(column) LIKE LOWER(keyword) when set to true.

'case_insensitive' => true,

Wild Card Search

Wild card will add % in between every characters of the keyword. The sql generated will be like column LIKE "%k%e%y%w%o%r%d%" when set to true.

'use_wildcards' => false,

Index Column

DataTables internal index id response column name.

'index_column' => 'DT_Row_Index',

Fractal Includes

Request key name to parse includes on fractal.

'includes' => 'include',

Fractal Serializer

Default fractal serializer to be used when serializing the response.

'serializer' => League\Fractal\Serializer\DataArraySerializer::class,

Script Template

DataTables html builder script blade template. If published, the file will installed on resources/views/vendor/datatables/script.blade.php.

'script_template' => 'datatables::script',

Artisan Console Configurations

Namespace configuration is used by the datatables command generator.

'namespace' => [
'base' => 'DataTables',
'model' => '',
],

DataTable Base Namespace/Directory

This is the base namespace/directory to be created when a new DataTable was called. This directory is appended on 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 model's are located. This directory is appended on default Laravel namespace. 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.

Available generators are: excel, snappy

Excel Generator (Default Generator)

When excel is used as the generator, the package will use maatwebsite/excel to generate the PDF.

To export files to pdf, you will have to include "dompdf/dompdf": "~0.6.1", "mpdf/mpdf": "~5.7.3" or "tecnick.com/tcpdf": "~6.0.0" in your composer.json and change the export.pdf.driver config setting accordingly.

Snappy Generator

When snappy is used as the generator, you need to install barryvdh/laravel-snappy

Snappy PDF Options

These are the options passed to laravel-snappy when exporting the pdf file.

'snappy' => [
'options' => [
'no-outline' => true,
'margin-left' => '0',
'margin-right' => '0',
'margin-top' => '10mm',
'margin-bottom' => '10mm',
],
'orientation' => 'landscape',
],