From f02eb61169ca9e70336b473a35c42c808c62df45 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 11:01:44 +0800 Subject: [PATCH 001/264] Add reset and reload buttons. --- buttons-export.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++- documentation.md | 5 +---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/buttons-export.md b/buttons-export.md index b5d54e2..43b1d9a 100644 --- a/buttons-export.md +++ b/buttons-export.md @@ -129,4 +129,56 @@ class UsersDataTable extends DataTable ]); } ... -``` \ No newline at end of file +``` + + +## Reset Button + +To enable reset button, set `reset` on the buttons array. + +```php +namespace App\DataTables; + +use App\User; +use Yajra\Datatables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + //...some default stubs deleted for simplicity. + + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->parameters([ + 'buttons' => ['reset'], + ]); + } +... +``` + + +## Reload Button + +To enable reload button, set `reload` on the buttons array. + +```php +namespace App\DataTables; + +use App\User; +use Yajra\Datatables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + //...some default stubs deleted for simplicity. + + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->parameters([ + 'buttons' => ['reload'], + ]); + } +... +``` diff --git a/documentation.md b/documentation.md index e39643c..35fad64 100644 --- a/documentation.md +++ b/documentation.md @@ -68,9 +68,6 @@ - [Installation](/docs/laravel-datatables/{{version}}/buttons-installation) - [Configuration](/docs/laravel-datatables/{{version}}/buttons-config) - [Quick Starter](/docs/laravel-datatables/{{version}}/buttons-starter) - - [Excel](/docs/laravel-datatables/{{version}}/buttons-export#excel) - - [CSV](/docs/laravel-datatables/{{version}}/buttons-export#csv) - - [PDF](/docs/laravel-datatables/{{version}}/buttons-export#pdf) - - [Print](/docs/laravel-datatables/{{version}}/buttons-export#print) + - [DataTable Buttons](/docs/laravel-datatables/{{version}}/buttons-export) - [Artisan Console](/docs/laravel-datatables/{{version}}/buttons-console) From 475f350e193f6e97a981b33b265bc65ad832425b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 11:18:43 +0800 Subject: [PATCH 002/264] Add release notes for v7.0. --- releases.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/releases.md b/releases.md index abf7bde..a3aaf4c 100644 --- a/releases.md +++ b/releases.md @@ -1 +1,17 @@ -# Release Notes \ No newline at end of file +# Release Notes + +- [Laravel Datatables 7.0](#7.0) + + +## Laravel Datatables 7.0 + +Laravel Datatable 7.0 splits Laravel Datatable 6.x into a main package and plugins packages for more flexibile and pluggable design. + +### Buttons Plugin +On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. +This idea comes up from [Issue #832](https://github.com/yajra/laravel-datatables/issues/832) which actually makes sense since not all users are using the export functionality. + +### DomPDF +`DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. +And the `Buttons` plugin will now give you a choice to install or not. +This was also set to optional since we now have an option to use [`laravel-snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. From de3276e9be00f826e80969078c74d1449e40af28 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 13:38:42 +0800 Subject: [PATCH 003/264] Add script template. --- general-settings.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/general-settings.md b/general-settings.md index ac41cfc..bae9c53 100644 --- a/general-settings.md +++ b/general-settings.md @@ -83,4 +83,12 @@ Default fractal serializer to be used when serializing the response. ```php '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`. + +```php +'script_template' => 'datatables::script', +``` From 7c5ecc8813fe4a0e698b2ba322ef7db88b135163 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 13:40:14 +0800 Subject: [PATCH 004/264] Update buttons config. --- buttons-config.md | 107 ++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/buttons-config.md b/buttons-config.md index 470c84c..9887c42 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -1,57 +1,62 @@ # Buttons Configurations + +## Artisan Console Configurations +Namespace configuration is used by the datatables command generator. + ```php -return [ - /** - * DataTables script view template. - */ - 'script_template' => 'datatables::script', - - /** - * Namespaces used by the generator. - */ - 'namespace' => [ - /** - * Base namespace/directory to create the new file. - * This is appended on default Laravel namespace. - * Usage: php artisan datatables:make User - * Output: App\DataTables\UserDataTable - * With Model: App\User (default model) - * Export filename: users_timestamp - */ - 'base' => 'DataTables', - - /** - * Base namespace/directory where your model's are located. - * This 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 - */ - 'model' => '', - ], +'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 to be used when converting the table to pdf. - * Available generators: excel, snappy - * Snappy package: barryvdh/laravel-snappy - * Excel package: maatwebsite/excel - */ - 'pdf_generator' => 'excel', - - /** - * Snappy PDF options. - */ - 'snappy' => [ - 'options' => [ - 'no-outline' => true, - 'margin-left' => '0', - 'margin-right' => '0', - 'margin-top' => '10mm', - 'margin-bottom' => '10mm', - ], - 'orientation' => 'landscape', + +## 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`](http://www.maatwebsite.nl/laravel-excel/docs) 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`](https://github.com/barryvdh/laravel-snappy) + +### Snappy PDF Options +These are the options passed to `laravel-snappy` when exporting the pdf file. + +```php +'snappy' => [ + 'options' => [ + 'no-outline' => true, + 'margin-left' => '0', + 'margin-right' => '0', + 'margin-top' => '10mm', + 'margin-bottom' => '10mm', ], -]; + 'orientation' => 'landscape', +], ``` From 93c7d79ade6c2e547e411597f7a897b1322060f8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:24:36 +0800 Subject: [PATCH 005/264] Update introduction. --- introduction.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/introduction.md b/introduction.md index dd590b7..21cd603 100644 --- a/introduction.md +++ b/introduction.md @@ -1,6 +1,24 @@ # Introduction -## jQuery DataTables API for Laravel + +## Laravel +The PHP Framework For Web Artisans. + +Laravel is a web application framework with expressive, elegant syntax. +We believe development must be an enjoyable, creative experience to be truly fulfilling. +Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as: + +Official documentation of Laravel is available at [laravel.com](https://laravel.com/) + + +## DataTables +DataTables is a plug-in for the [jQuery](https://jquery.com/) Javascript library. +It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table. + +Official documentation of DataTables is available at [datatables.net](https://datatables.net) + + +## Laravel DataTables [![Join the chat at https://gitter.im/yajra/laravel-datatables](https://badges.gitter.im/yajra/laravel-datatables.svg)](https://gitter.im/yajra/laravel-datatables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![License](https://poser.pugx.org/yajra/laravel-datatables-oracle/license)](https://packagist.org/packages/yajra/laravel-datatables-oracle) @@ -11,22 +29,6 @@ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/laravel-datatables/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/laravel-datatables/?branch=master) [![Total Downloads](https://poser.pugx.org/yajra/laravel-datatables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-datatables-oracle) -This package is created to handle [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) jQuery Plugin via [AJAX option](https://datatables.net/reference/option/ajax) by using Eloquent ORM, Fluent Query Builder or Collection. - -```php -use Yajra\Datatables\Facades\Datatables; - -// Using Eloquent -return Datatables::eloquent(User::query())->make(true); - -// Using Query Builder -return Datatables::queryBuilder(DB::table('users'))->make(true); +Laravel DataTables is a package that handles the [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) using [Laravel](http://laravel.com). -// Using Collection -return Datatables::collection(User::all())->make(true); -// Using the Engine Factory -return Datatables::of(User::query())->make(true); -return Datatables::of(DB::table('users'))->make(true); -return Datatables::of(User::all())->make(true); -``` From e3270e575fe5d762622584202a6bcbe097741343 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:29:33 +0800 Subject: [PATCH 006/264] Fix typo. --- html-builder-callbacks.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-callbacks.md b/html-builder-callbacks.md index 1e78d93..43966af 100644 --- a/html-builder-callbacks.md +++ b/html-builder-callbacks.md @@ -18,4 +18,4 @@ You can use a `js` string for each valid callback as documented on [`datatables. |`stateLoaded` | State loaded callback. | |`stateLoadParams` | State loaded - data manipulation callback | |`stateSaveCallback` | Callback that defines how the table state is stored and where. | -|`stateSaveParams` | State save - data manipulation callbac | +|`stateSaveParams` | State save - data manipulation callback | From 1d8271877d2eef016e5022cd2bca832043113dec Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:32:35 +0800 Subject: [PATCH 007/264] Add event callback example. --- html-builder-callbacks.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/html-builder-callbacks.md b/html-builder-callbacks.md index 43966af..b48b3fc 100644 --- a/html-builder-callbacks.md +++ b/html-builder-callbacks.md @@ -19,3 +19,12 @@ You can use a `js` string for each valid callback as documented on [`datatables. |`stateLoadParams` | State loaded - data manipulation callback | |`stateSaveCallback` | Callback that defines how the table state is stored and where. | |`stateSaveParams` | State save - data manipulation callback | + +## Example +In this example, we will hook on the the `drawCallback` of dataTable. + +```php +$builder->parameters([ + 'drawCallback' => 'function() { alert("Table Draw Callback") }', +]); +``` \ No newline at end of file From fe2bb4489ed8984b76f33e09a9cdf32133a3ab3f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:41:11 +0800 Subject: [PATCH 008/264] Fix typo. --- releases.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/releases.md b/releases.md index a3aaf4c..6218c61 100644 --- a/releases.md +++ b/releases.md @@ -5,7 +5,7 @@ ## Laravel Datatables 7.0 -Laravel Datatable 7.0 splits Laravel Datatable 6.x into a main package and plugins packages for more flexibile and pluggable design. +Laravel Datatables 7.0 splits Laravel Datatables 6.x into a main package and plugins packages for more flexibile and pluggable design. ### Buttons Plugin On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. @@ -13,5 +13,5 @@ This idea comes up from [Issue #832](https://github.com/yajra/laravel-datatables ### DomPDF `DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. -And the `Buttons` plugin will now give you a choice to install or not. -This was also set to optional since we now have an option to use [`laravel-snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. +And the `Buttons` plugin will now give you a choice to install it or not. +This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. From 5fdb30b5ecec6d30ecde66c5a61db6cc44a12839 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:49:33 +0800 Subject: [PATCH 009/264] Add buttons verion and link to github. --- buttons-installation.md | 2 +- documentation.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/buttons-installation.md b/buttons-installation.md index c8d07f2..86f48c9 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons` +`composer require yajra/laravel-datatables-buttons:^1.0` Open the file ```config/app.php``` and then add following service provider. diff --git a/documentation.md b/documentation.md index 35fad64..030d977 100644 --- a/documentation.md +++ b/documentation.md @@ -70,4 +70,5 @@ - [Quick Starter](/docs/laravel-datatables/{{version}}/buttons-starter) - [DataTable Buttons](/docs/laravel-datatables/{{version}}/buttons-export) - [Artisan Console](/docs/laravel-datatables/{{version}}/buttons-console) + - [Github](https://github.com/yajra/laravel-datatables-buttons) From 3b1a05953da64790284cf056b7f031a1337e6db5 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 14:51:29 +0800 Subject: [PATCH 010/264] Add version constraints. --- installation.md | 2 +- upgrade.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/installation.md b/installation.md index 40d2b94..46a801c 100644 --- a/installation.md +++ b/installation.md @@ -23,7 +23,7 @@ Laravel Datatables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ``` -composer require yajra/laravel-datatables-oracle +composer require yajra/laravel-datatables-oracle:^7.0 ``` diff --git a/upgrade.md b/upgrade.md index c96544b..9bb7745 100644 --- a/upgrade.md +++ b/upgrade.md @@ -2,8 +2,8 @@ ## Upgrading from v6.x to v7.x - - composer require yajra/laravel-datatables-oracle - - composer require yajra/laravel-datatables-buttons + - composer require yajra/laravel-datatables-oracle:^7.0 + - composer require yajra/laravel-datatables-buttons:^1.0 - php artisan vendor:publish --tag=datatables --force - php artisan vendor:publish --tag=datatables-buttons --force From 2018d5cd8caa8bda4ca83740d0d7d07942bf66d7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 15:35:26 +0800 Subject: [PATCH 011/264] Add runtime smart search docs. --- documentation.md | 1 + smart-search.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 smart-search.md diff --git a/documentation.md b/documentation.md index 030d977..a513466 100644 --- a/documentation.md +++ b/documentation.md @@ -40,6 +40,7 @@ - [Filter Column](/docs/laravel-datatables/{{version}}/filter-column) - [Query Builder Extension](/docs/laravel-datatables/{{version}}/query-builder) - [Regex Search](/docs/laravel-datatables/{{version}}/regex) + - [Smart Search](/docs/laravel-datatables/{{version}}/smart-search) - Sorting/Ordering - [Manual Order](/docs/laravel-datatables/{{version}}/manual-order) - [Order Column](/docs/laravel-datatables/{{version}}/order-column) diff --git a/smart-search.md b/smart-search.md new file mode 100644 index 0000000..df3ab5a --- /dev/null +++ b/smart-search.md @@ -0,0 +1,16 @@ +# Runtime Smart Search + +You can optionally enable/disable Datatables smart search feature by using `smart` api by passing `true` or `false` as the argument. +Default argument value is `true`. + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return Datatables::eloquent($model) + ->smart(false) + ->make(true); +}); +``` \ No newline at end of file From dfa21d3ee60ec09c2f8c3b82c6c2ec44bddaf75c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 15:43:17 +0800 Subject: [PATCH 012/264] Add serializer docs. --- documentation.md | 1 + response-fractal-serializer.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 response-fractal-serializer.md diff --git a/documentation.md b/documentation.md index a513466..3f8c73e 100644 --- a/documentation.md +++ b/documentation.md @@ -23,6 +23,7 @@ - [Array Response](/docs/laravel-datatables/{{version}}/response-array) - [Object Response](/docs/laravel-datatables/{{version}}/response-object) - [Fractal Transformer](/docs/laravel-datatables/{{version}}/response-fractal) + - [Fractal Serializer](/docs/laravel-datatables/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/laravel-datatables/{{version}}/response-with) - Column Editing - [Add Column](/docs/laravel-datatables/{{version}}/add-column) diff --git a/response-fractal-serializer.md b/response-fractal-serializer.md new file mode 100644 index 0000000..ac4ddc5 --- /dev/null +++ b/response-fractal-serializer.md @@ -0,0 +1,16 @@ +# Fractal Transformer Serializer + +You can set the serializer to be used by Datatables using `setSerializer` api. Serializer should be used with `setTransformer` api. + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return Datatables::eloquent($model) + ->setTransformer(new App\Transformers\UserTransformer) + ->setSerializer(new App\Serializers\CustomSerializer) + ->make(true); +}); +``` \ No newline at end of file From 1643ddd616ba77caf39aef8fec39b36c3f4692e1 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 16:49:06 +0800 Subject: [PATCH 013/264] Add orderByNullsLast docs. --- documentation.md | 1 + order-by-nulls-last.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 order-by-nulls-last.md diff --git a/documentation.md b/documentation.md index 3f8c73e..1307a0a 100644 --- a/documentation.md +++ b/documentation.md @@ -46,6 +46,7 @@ - [Manual Order](/docs/laravel-datatables/{{version}}/manual-order) - [Order Column](/docs/laravel-datatables/{{version}}/order-column) - [Order Columns](/docs/laravel-datatables/{{version}}/order-columns) + - [Order Nulls Last](/docs/laravel-datatables/{{version}}/order-by-nulls-last) - Utilities - [XSS filtering](/docs/laravel-datatables/{{version}}/xss) - [Blacklist Columns](/docs/laravel-datatables/{{version}}/blacklist) diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md new file mode 100644 index 0000000..bca1a78 --- /dev/null +++ b/order-by-nulls-last.md @@ -0,0 +1,15 @@ +# Order by NULLS LAST + +This api will set Datatables to perform ordering with `NULLS LAST` option. + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return Datatables::eloquent($model) + ->orderByNullsLast() + ->make(true); +}); +``` From cff1e56c43189c1f7003731d888b535b8877473a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 17 Nov 2016 17:46:54 +0800 Subject: [PATCH 014/264] Add nulls last docs. --- documentation.md | 2 +- general-settings.md | 10 ++++++++++ order-by-nulls-last.md | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/documentation.md b/documentation.md index 1307a0a..d368a77 100644 --- a/documentation.md +++ b/documentation.md @@ -46,7 +46,7 @@ - [Manual Order](/docs/laravel-datatables/{{version}}/manual-order) - [Order Column](/docs/laravel-datatables/{{version}}/order-column) - [Order Columns](/docs/laravel-datatables/{{version}}/order-columns) - - [Order Nulls Last](/docs/laravel-datatables/{{version}}/order-by-nulls-last) + - [Order By Nulls Last](/docs/laravel-datatables/{{version}}/order-by-nulls-last) - Utilities - [XSS filtering](/docs/laravel-datatables/{{version}}/xss) - [Blacklist Columns](/docs/laravel-datatables/{{version}}/blacklist) diff --git a/general-settings.md b/general-settings.md index bae9c53..f1cac2f 100644 --- a/general-settings.md +++ b/general-settings.md @@ -92,3 +92,13 @@ If published, the file will installed on `resources/views/vendor/datatables/scri 'script_template' => 'datatables::script', ``` + +## NULLS LAST sql +Nulls last sql pattern for Postgresql & Oracle. + +> {tip} For MySQL, use '-%s %s' as the sql pattern. + +```php +'nulls_last_sql' => '%s %s NULLS LAST', +``` + diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index bca1a78..2d3d523 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -13,3 +13,5 @@ Route::get('user-data', function() { ->make(true); }); ``` + +> You must update [nulls_last_sql](/docs/laravel-datatables/{{version}}/general-settings#nulls-last-sql) config and use a pattern that matches your DB Driver. From c2cbf0def5ab8a684d7ab65c98e64bf1798353ce Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 18 Nov 2016 09:07:03 +0800 Subject: [PATCH 015/264] Add builder parameters example. --- html-builder-parameters.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/html-builder-parameters.md b/html-builder-parameters.md index 356b1b9..cd60c84 100644 --- a/html-builder-parameters.md +++ b/html-builder-parameters.md @@ -3,3 +3,17 @@ Parameters are basically the options you pass when declaring your `DataTable` js script. See the [`datatables.net`](https://datatables.net) official documentation for the list of all possible [`options`](https://datatables.net/reference/option/). + + +## Example +```php +$builder->parameters([ + 'paging' => true, + 'searching' => true, + 'info' => false, + 'searchDelay' => 350, + 'language' => [ + 'url' => url('js/dataTables/language.json') + ], +]); +``` \ No newline at end of file From 04eea8434714bc06d7c7ed55d55bed9e427af3ea Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 18 Nov 2016 20:39:21 +0800 Subject: [PATCH 016/264] Use package var. --- documentation.md | 110 ++++++++++++++++++++--------------------- html-builder-column.md | 4 +- html-builder-index.md | 2 +- index-column.md | 2 +- introduction.md | 2 +- order-by-nulls-last.md | 2 +- releases.md | 2 +- 7 files changed, 62 insertions(+), 62 deletions(-) diff --git a/documentation.md b/documentation.md index d368a77..31f6fb1 100644 --- a/documentation.md +++ b/documentation.md @@ -1,77 +1,77 @@ - Prologue - - [Release Notes](/docs/laravel-datatables/{{version}}/releases) - - [Upgrade Guide](/docs/laravel-datatables/{{version}}/upgrade) - - [Contribution Guide](/docs/laravel-datatables/{{version}}/contributing) - - [Security Issues](/docs/laravel-datatables/{{version}}/security) - - [API Documentation](http://yajra.github.io/laravel-datatables/api/{{version}}) + - [Release Notes](/docs/{{package}}/{{version}}/releases) + - [Upgrade Guide](/docs/{{package}}/{{version}}/upgrade) + - [Contribution Guide](/docs/{{package}}/{{version}}/contributing) + - [Security Issues](/docs/{{package}}/{{version}}/security) + - [API Documentation](http://yajra.github.io/{{package}}/api/{{version}}) - Setup - - [Installation](/docs/laravel-datatables/{{version}}/installation) + - [Installation](/docs/{{package}}/{{version}}/installation) - Getting Started - - [Introduction](/docs/laravel-datatables/{{version}}/introduction) + - [Introduction](/docs/{{package}}/{{version}}/introduction) - [Demo Application](https://datatables.yajrabox.com/) - Tutorials - [Quick Starter](https://datatables.yajrabox.com/starter) - [Service Implementation](https://datatables.yajrabox.com/service) - Configuration - - [General Settings](/docs/laravel-datatables/{{version}}/general-settings) - - [Debugging Mode](/docs/laravel-datatables/{{version}}/debugger) + - [General Settings](/docs/{{package}}/{{version}}/general-settings) + - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - Engines & Data Sources - - [Eloquent](/docs/laravel-datatables/{{version}}/engine-eloquent) - - [Query Builder](/docs/laravel-datatables/{{version}}/engine-query) - - [Collection](/docs/laravel-datatables/{{version}}/engine-collection) + - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) + - [Query Builder](/docs/{{package}}/{{version}}/engine-query) + - [Collection](/docs/{{package}}/{{version}}/engine-collection) - Response - - [Array Response](/docs/laravel-datatables/{{version}}/response-array) - - [Object Response](/docs/laravel-datatables/{{version}}/response-object) - - [Fractal Transformer](/docs/laravel-datatables/{{version}}/response-fractal) - - [Fractal Serializer](/docs/laravel-datatables/{{version}}/response-fractal-serializer) - - [Additional Data Response](/docs/laravel-datatables/{{version}}/response-with) + - [Array Response](/docs/{{package}}/{{version}}/response-array) + - [Object Response](/docs/{{package}}/{{version}}/response-object) + - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) + - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) + - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) - Column Editing - - [Add Column](/docs/laravel-datatables/{{version}}/add-column) - - [Edit Column](/docs/laravel-datatables/{{version}}/edit-column) - - [Remove Column](/docs/laravel-datatables/{{version}}/remove-column) - - [Index Column](/docs/laravel-datatables/{{version}}/index-column) + - [Add Column](/docs/{{package}}/{{version}}/add-column) + - [Edit Column](/docs/{{package}}/{{version}}/edit-column) + - [Remove Column](/docs/{{package}}/{{version}}/remove-column) + - [Index Column](/docs/{{package}}/{{version}}/index-column) - Row Editing - - [Row Options](/docs/laravel-datatables/{{version}}/row-options) - - [Row ID](/docs/laravel-datatables/{{version}}/row-options#row-id) - - [Row Class](/docs/laravel-datatables/{{version}}/row-options#row-class) - - [Row Data](/docs/laravel-datatables/{{version}}/row-options#row-data) - - [Row Attributes](/docs/laravel-datatables/{{version}}/row-options#row-attributes) + - [Row Options](/docs/{{package}}/{{version}}/row-options) + - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) + - [Row Class](/docs/{{package}}/{{version}}/row-options#row-class) + - [Row Data](/docs/{{package}}/{{version}}/row-options#row-data) + - [Row Attributes](/docs/{{package}}/{{version}}/row-options#row-attributes) - Searching - - [Manual Search](/docs/laravel-datatables/{{version}}/manual-search) - - [Filter Column](/docs/laravel-datatables/{{version}}/filter-column) - - [Query Builder Extension](/docs/laravel-datatables/{{version}}/query-builder) - - [Regex Search](/docs/laravel-datatables/{{version}}/regex) - - [Smart Search](/docs/laravel-datatables/{{version}}/smart-search) + - [Manual Search](/docs/{{package}}/{{version}}/manual-search) + - [Filter Column](/docs/{{package}}/{{version}}/filter-column) + - [Query Builder Extension](/docs/{{package}}/{{version}}/query-builder) + - [Regex Search](/docs/{{package}}/{{version}}/regex) + - [Smart Search](/docs/{{package}}/{{version}}/smart-search) - Sorting/Ordering - - [Manual Order](/docs/laravel-datatables/{{version}}/manual-order) - - [Order Column](/docs/laravel-datatables/{{version}}/order-column) - - [Order Columns](/docs/laravel-datatables/{{version}}/order-columns) - - [Order By Nulls Last](/docs/laravel-datatables/{{version}}/order-by-nulls-last) + - [Manual Order](/docs/{{package}}/{{version}}/manual-order) + - [Order Column](/docs/{{package}}/{{version}}/order-column) + - [Order Columns](/docs/{{package}}/{{version}}/order-columns) + - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) - Utilities - - [XSS filtering](/docs/laravel-datatables/{{version}}/xss) - - [Blacklist Columns](/docs/laravel-datatables/{{version}}/blacklist) - - [Whitelist Columns](/docs/laravel-datatables/{{version}}/whitelist) - - [Set Total Records](/docs/laravel-datatables/{{version}}/set-total-records) - - [With Trashed](/docs/laravel-datatables/{{version}}/with-trashed) - - [Skip Paging](/docs/laravel-datatables/{{version}}/skip-paging) + - [XSS filtering](/docs/{{package}}/{{version}}/xss) + - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) + - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) + - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) + - [With Trashed](/docs/{{package}}/{{version}}/with-trashed) + - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) - HTML Builder - - [Builder](/docs/laravel-datatables/{{version}}/html-builder) - - [Table](/docs/laravel-datatables/{{version}}/html-builder-table) - - [Columns](/docs/laravel-datatables/{{version}}/html-builder-column) - - [Ajax](/docs/laravel-datatables/{{version}}/html-builder-ajax) - - [Parameters](/docs/laravel-datatables/{{version}}/html-builder-parameters) - - [Events/Callbacks](/docs/laravel-datatables/{{version}}/html-builder-callbacks) - - [Add Action](/docs/laravel-datatables/{{version}}/html-builder-action) - - [Add Checkbox](/docs/laravel-datatables/{{version}}/html-builder-checkbox) - - [Add Index](/docs/laravel-datatables/{{version}}/html-builder-index) + - [Builder](/docs/{{package}}/{{version}}/html-builder) + - [Table](/docs/{{package}}/{{version}}/html-builder-table) + - [Columns](/docs/{{package}}/{{version}}/html-builder-column) + - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) + - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) + - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) + - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) + - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) + - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) ### PLUGINS - Buttons - - [Installation](/docs/laravel-datatables/{{version}}/buttons-installation) - - [Configuration](/docs/laravel-datatables/{{version}}/buttons-config) - - [Quick Starter](/docs/laravel-datatables/{{version}}/buttons-starter) - - [DataTable Buttons](/docs/laravel-datatables/{{version}}/buttons-export) - - [Artisan Console](/docs/laravel-datatables/{{version}}/buttons-console) + - [Installation](/docs/{{package}}/{{version}}/buttons-installation) + - [Configuration](/docs/{{package}}/{{version}}/buttons-config) + - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) + - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) + - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) diff --git a/html-builder-column.md b/html-builder-column.md index 162c0d8..7dd9748 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -55,9 +55,9 @@ Footer attribute will be as your `tables` column's `footer` content ` Exportable attribute should be used with the [Buttons Plugin](/docs/laravel-datatables/{{version}}/buttons-installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) ### Printable (Optional) Printable attribute will flag the column to be included when `printing` the table. Default value is `true`. -> Exportable attribute should be used with the [Buttons Plugin](/docs/laravel-datatables/{{version}}/buttons-installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) diff --git a/html-builder-index.md b/html-builder-index.md index b29845f..8cf4690 100644 --- a/html-builder-index.md +++ b/html-builder-index.md @@ -19,4 +19,4 @@ The default attributes of index column are: ]; ``` -The `addIndex` api should be used along with [`addIndexColumn`](/docs/laravel-datatables/{{version}}/index-column) of `Datatables`. \ No newline at end of file +The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `Datatables`. \ No newline at end of file diff --git a/index-column.md b/index-column.md index 0df994d..396b499 100644 --- a/index-column.md +++ b/index-column.md @@ -15,5 +15,5 @@ Route::get('user-data', function() { }); ``` -Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/laravel-datatables/{{version}}/general-settings#index-column) configuration. +Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. The default index column name is `DT_Row_Index` \ No newline at end of file diff --git a/introduction.md b/introduction.md index 21cd603..fc30ba1 100644 --- a/introduction.md +++ b/introduction.md @@ -26,7 +26,7 @@ Official documentation of DataTables is available at [datatables.net](https://da [![Laravel 4.2|5.x](https://img.shields.io/badge/Laravel-4.2|5.x-orange.svg)](http://laravel.com) [![Latest Stable Version](https://poser.pugx.org/yajra/laravel-datatables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-datatables-oracle) [![Build Status](https://travis-ci.org/yajra/laravel-datatables.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/laravel-datatables/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/laravel-datatables/?branch=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/{{package}}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/{{package}}/?branch=master) [![Total Downloads](https://poser.pugx.org/yajra/laravel-datatables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-datatables-oracle) Laravel DataTables is a package that handles the [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) using [Laravel](http://laravel.com). diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index 2d3d523..d2fc0ef 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -14,4 +14,4 @@ Route::get('user-data', function() { }); ``` -> You must update [nulls_last_sql](/docs/laravel-datatables/{{version}}/general-settings#nulls-last-sql) config and use a pattern that matches your DB Driver. +> You must update [nulls_last_sql](/docs/{{package}}/{{version}}/general-settings#nulls-last-sql) config and use a pattern that matches your DB Driver. diff --git a/releases.md b/releases.md index 6218c61..1dd8913 100644 --- a/releases.md +++ b/releases.md @@ -9,7 +9,7 @@ Laravel Datatables 7.0 splits Laravel Datatables 6.x into a main package and plu ### Buttons Plugin On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. -This idea comes up from [Issue #832](https://github.com/yajra/laravel-datatables/issues/832) which actually makes sense since not all users are using the export functionality. +This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues/832) which actually makes sense since not all users are using the export functionality. ### DomPDF `DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. From 5cba1fc76dc0e8fe32caccc235f5eaf42ad51b1b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 19 Nov 2016 16:27:21 +0800 Subject: [PATCH 017/264] Add relationship docs. --- documentation.md | 1 + relationships.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 relationships.md diff --git a/documentation.md b/documentation.md index 31f6fb1..6ec3a03 100644 --- a/documentation.md +++ b/documentation.md @@ -42,6 +42,7 @@ - [Query Builder Extension](/docs/{{package}}/{{version}}/query-builder) - [Regex Search](/docs/{{package}}/{{version}}/regex) - [Smart Search](/docs/{{package}}/{{version}}/smart-search) + - [Relationships](/docs/{{package}}/{{version}}/relationships) - Sorting/Ordering - [Manual Order](/docs/{{package}}/{{version}}/manual-order) - [Order Column](/docs/{{package}}/{{version}}/order-column) diff --git a/relationships.md b/relationships.md new file mode 100644 index 0000000..728fe74 --- /dev/null +++ b/relationships.md @@ -0,0 +1,51 @@ +# Eager Loading Relationships + +`Datatables` support searching and sorting of eager loaded relationships when using `Eloquent`. +In this example, I will show you how to setup a eager loading search using `EloquentEngine`. + +To enable search, we need to eager load the relationship we intend to use using Laravel's `User::with('posts')` api. + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::with('posts'); + + return Datatables::eloquent($model) + ->addColumn('posts', function (User $user) { + return $user->posts->map(function($post) { + return str_limit($post->title, 30, '...'); + })->implode('
'); + }) + ->make(true); +}); +``` + +To trigger search on `posts` relationship, we need to specify the `relation.column_name` as the `name` attribute in our `javascript` appropriately. + +```php + +``` + +Looking at `{data: 'posts', name: 'posts.title'},`: +- `data: posts` represents the data key (`data.posts`) that we are going to display on our table. +- `name: posts.title` represents the `User` model relationship (`posts`) and the column we are going to perform our search (`title`). + +## Nested Relationships +Same strategy goes for nested relationships but do **NOTE** that ordering is not yet fully tested on nested relationships. + From 8758d4dccc1c75dad97df0de031641dd5699196f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 19 Nov 2016 16:27:28 +0800 Subject: [PATCH 018/264] Update release docs. --- releases.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/releases.md b/releases.md index 1dd8913..6659c2f 100644 --- a/releases.md +++ b/releases.md @@ -15,3 +15,13 @@ This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues `DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. And the `Buttons` plugin will now give you a choice to install it or not. This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. + +### Other Changes + +#### Request property +`Datatables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. + +```php +$dataTable = Datatable::of(User::query()); +$request = $dataTable->getRequest(); +``` From ade8bf2996dedf520cd2acb6980405d4fc61d1c7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 19 Nov 2016 16:31:49 +0800 Subject: [PATCH 019/264] Fix js. --- relationships.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/relationships.md b/relationships.md index 728fe74..91f1b29 100644 --- a/relationships.md +++ b/relationships.md @@ -27,17 +27,18 @@ To trigger search on `posts` relationship, we need to specify the `relation.colu ``` From e8766a3a7787aea92fffa2215b3de4703087a36b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 26 Jan 2017 17:02:01 +0800 Subject: [PATCH 020/264] Move HTML builder to plugins. --- documentation.md | 6 ++++-- html-installation.md | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 html-installation.md diff --git a/documentation.md b/documentation.md index 6ec3a03..204825e 100644 --- a/documentation.md +++ b/documentation.md @@ -55,7 +55,11 @@ - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) - [With Trashed](/docs/{{package}}/{{version}}/with-trashed) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) + +### PLUGINS + - HTML Builder + - [Installation](/docs/{{package}}/{{version}}/html-installation) - [Builder](/docs/{{package}}/{{version}}/html-builder) - [Table](/docs/{{package}}/{{version}}/html-builder-table) - [Columns](/docs/{{package}}/{{version}}/html-builder-column) @@ -66,8 +70,6 @@ - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) -### PLUGINS - - Buttons - [Installation](/docs/{{package}}/{{version}}/buttons-installation) - [Configuration](/docs/{{package}}/{{version}}/buttons-config) diff --git a/html-installation.md b/html-installation.md new file mode 100644 index 0000000..8af414d --- /dev/null +++ b/html-installation.md @@ -0,0 +1,23 @@ +# HTML Builder Plugin + +## Installation + +Run the following command in your project to get the latest version of the plugin: + +`composer require yajra/laravel-datatables-html:^1.0` + +Open the file ```config/app.php``` and then add following service provider. + +```php +'providers' => [ + // ... + Yajra\Datatables\DatatablesServiceProvider::class, + Yajra\Datatables\HtmlServiceProvider::class, +], +``` + +After completing the step above, use the following command to publish configuration & assets: + +``` +php artisan vendor:publish --tag=datatables-html +``` From d878441fed5beadc42afb3f566b124b39b54f5d2 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 26 Jan 2017 17:06:10 +0800 Subject: [PATCH 021/264] Update requirements. --- installation.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/installation.md b/installation.md index 46a801c..f704375 100644 --- a/installation.md +++ b/installation.md @@ -11,8 +11,7 @@ ### Requirements -- [PHP >=5.5.9](http://php.net/) -- [Laravel 5.x](https://github.com/laravel/framework) +- [Laravel 5.4](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) From bb06ff30fe86a2c25b5379fdf6600ce0860fac99 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 26 Jan 2017 17:07:22 +0800 Subject: [PATCH 022/264] Add html github link. --- documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.md b/documentation.md index 204825e..7c5cba6 100644 --- a/documentation.md +++ b/documentation.md @@ -69,6 +69,7 @@ - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) + - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons - [Installation](/docs/{{package}}/{{version}}/buttons-installation) From 214d4f0adac44374553c6245c440b9aeef95e5a9 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 30 Jan 2017 08:33:46 +0800 Subject: [PATCH 023/264] Add XSS protection notes. --- upgrade.md | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/upgrade.md b/upgrade.md index 9bb7745..a4bd68b 100644 --- a/upgrade.md +++ b/upgrade.md @@ -2,15 +2,26 @@ ## Upgrading from v6.x to v7.x - - composer require yajra/laravel-datatables-oracle:^7.0 - - composer require yajra/laravel-datatables-buttons:^1.0 - - php artisan vendor:publish --tag=datatables --force - - php artisan vendor:publish --tag=datatables-buttons --force +- composer require yajra/laravel-datatables-oracle:^7.0 +- composer require yajra/laravel-datatables-buttons:^1.0 +- php artisan vendor:publish --tag=datatables --force +- php artisan vendor:publish --tag=datatables-buttons --force +### XSS Protection +All columns are now escaped by default to protect us XSS attack. To allow columns to have an html content, use `rawColumns` api. + +```php +Datatables::of(User::query()) + ->addColumn('href', 'Html Content') + ->rawColumns(['href']) + ->make(true); +``` + + ## Upgrading from v5.x to v6.x - - Change all occurrences of `yajra\Datatables` to `Yajra\Datatables`. (Use Sublime's find and replace all for faster update). - - Remove `Datatables` facade registration. - - Temporarily comment out `Yajra\Datatables\DatatablesServiceProvider`. - - Update package version on your composer.json and use `yajra/laravel-datatables-oracle: ~6.0` - - Uncomment the provider `Yajra\Datatables\DatatablesServiceProvider`. +- Change all occurrences of `yajra\Datatables` to `Yajra\Datatables`. (Use Sublime's find and replace all for faster update). +- Remove `Datatables` facade registration. +- Temporarily comment out `Yajra\Datatables\DatatablesServiceProvider`. +- Update package version on your composer.json and use `yajra/laravel-datatables-oracle: ~6.0` +- Uncomment the provider `Yajra\Datatables\DatatablesServiceProvider`. From 056482503aaf5d67ee8eb38f21e499510a4f4634 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 30 Jan 2017 08:36:29 +0800 Subject: [PATCH 024/264] Fix grammar. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index a4bd68b..5b4655e 100644 --- a/upgrade.md +++ b/upgrade.md @@ -8,7 +8,7 @@ - php artisan vendor:publish --tag=datatables-buttons --force ### XSS Protection -All columns are now escaped by default to protect us XSS attack. To allow columns to have an html content, use `rawColumns` api. +All columns are now escaped by default to protect us from XSS attack. To allow columns to have an html content, use `rawColumns` api. ```php Datatables::of(User::query()) From 70673c98d4e010b86abe0351a1dae81356e499fc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 30 Jan 2017 08:52:53 +0800 Subject: [PATCH 025/264] Add buttons and html plugin notes. --- upgrade.md | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/upgrade.md b/upgrade.md index 5b4655e..d7e4fca 100644 --- a/upgrade.md +++ b/upgrade.md @@ -2,10 +2,30 @@ ## Upgrading from v6.x to v7.x -- composer require yajra/laravel-datatables-oracle:^7.0 -- composer require yajra/laravel-datatables-buttons:^1.0 -- php artisan vendor:publish --tag=datatables --force -- php artisan vendor:publish --tag=datatables-buttons --force +To upgrade Laravel Datatable from version 6.x to version 7.x: + +```sh +composer require yajra/laravel-datatables-oracle:^7.0 +php artisan vendor:publish --tag=datatables --force +``` + +### Service Approach +Service class is now extracted to own plugin, `Buttons Plugin`. If you are using the service approach, you need to perform the following: + +```sh +composer require yajra/laravel-datatables-buttons:^1.0 +php artisan vendor:publish --tag=datatables-buttons --force +``` + +### Html Builder +HTML builder is now extracted to own plugin, If you are using Datatables html builder, you need to perform the following: +> {info} HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. + +```sh +composer require yajra/laravel-datatables-html:^1.0 +php artisan vendor:publish --tag=datatables-html --force +``` + ### XSS Protection All columns are now escaped by default to protect us from XSS attack. To allow columns to have an html content, use `rawColumns` api. From ec1975c6fe039296784e67b17f92c7ee08ff9e18 Mon Sep 17 00:00:00 2001 From: Guillaume Rauffet Date: Sat, 4 Feb 2017 11:06:26 +0100 Subject: [PATCH 026/264] Update html-builder-table.md Misplaced closing square bracket. --- html-builder-table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-table.md b/html-builder-table.md index 44c2db8..d57a894 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -34,7 +34,7 @@ On your `resources/views/users/index.blade.php`. @extends('app') @section('contents') - {!! $html->table(['class' => 'table table-bordered', true]) !!} +    {!! $html->table(['class' => 'table table-bordered'], true) !!} @endsection @push('scripts') From a7c758a63fdbe62824266ad39a26f1f8c0927d4e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 6 Feb 2017 11:09:17 +0800 Subject: [PATCH 027/264] Add note to register button service provider. --- upgrade.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/upgrade.md b/upgrade.md index d7e4fca..34140c8 100644 --- a/upgrade.md +++ b/upgrade.md @@ -14,9 +14,16 @@ Service class is now extracted to own plugin, `Buttons Plugin`. If you are using ```sh composer require yajra/laravel-datatables-buttons:^1.0 +``` + +Register `Yajra\Datatables\ButtonsServiceProder` on 'config/app.php' and publish config. + + +```php php artisan vendor:publish --tag=datatables-buttons --force ``` + ### Html Builder HTML builder is now extracted to own plugin, If you are using Datatables html builder, you need to perform the following: > {info} HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. From 8723d46a4c0aad2145cf1f1515be1bcfeee250d3 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 6 Feb 2017 11:13:53 +0800 Subject: [PATCH 028/264] Add rawColumn api docs. --- documentation.md | 1 + raw-columns.md | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 raw-columns.md diff --git a/documentation.md b/documentation.md index 7c5cba6..7c8a146 100644 --- a/documentation.md +++ b/documentation.md @@ -30,6 +30,7 @@ - [Edit Column](/docs/{{package}}/{{version}}/edit-column) - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) + - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) - Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) diff --git a/raw-columns.md b/raw-columns.md new file mode 100644 index 0000000..e612e3f --- /dev/null +++ b/raw-columns.md @@ -0,0 +1,20 @@ +# Raw Columns + +By default, Laravel DataTables protects us from XSS attack by esacping all our outputs. +In cases where you want to render an html content, please use `rawColumns` api. + + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return Datatables::eloquent($model) + ->addColumn('link', 'Html Column') + ->addColumn('action', 'path.to.view') + ->rawColumns(['link', 'action']) + ->make(true); +}); +``` + From 9934b1d274143c9a70c7509148d4eea62d41c36f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 6 Feb 2017 11:16:37 +0800 Subject: [PATCH 029/264] Add docs to unescaped columns. --- xss.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xss.md b/xss.md index ab5b8a7..d1ea985 100644 --- a/xss.md +++ b/xss.md @@ -19,6 +19,15 @@ return Datatables::eloquent(Role::select()) ->make(true); ``` + +## Remove escaping of all columns + +```php +return Datatables::eloquent(Role::select()) + ->escapeColumns([]) + ->make(true); +``` + ## Escape by output index From a47fa77d0a8915380d4dce7159252a0be6a19a77 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 15 Feb 2017 08:56:12 +0800 Subject: [PATCH 030/264] Fix buttons provider. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 34140c8..e5e446a 100644 --- a/upgrade.md +++ b/upgrade.md @@ -16,7 +16,7 @@ Service class is now extracted to own plugin, `Buttons Plugin`. If you are using composer require yajra/laravel-datatables-buttons:^1.0 ``` -Register `Yajra\Datatables\ButtonsServiceProder` on 'config/app.php' and publish config. +Register `Yajra\Datatables\ButtonsServiceProder::class` on `config/app.php` and publish config. ```php From 5d0e4c7680bc6427a26e673218e6c80ae12dc0d7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 15 Feb 2017 09:02:42 +0800 Subject: [PATCH 031/264] Fix version. --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 9dc60f3..084b4be 100644 --- a/readme.md +++ b/readme.md @@ -3,5 +3,5 @@ ## Contribution Guidelines If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. -For example, documentation for Laravel Datatables 5.1 would be submitted to the `5.1` branch. +For example, documentation for Laravel Datatables 6.0 would be submitted to the `6.0` branch. Documentation intended for the next release of Laravel Datatables should be submitted to the `master` branch. \ No newline at end of file From 7b187d09d93f4a410001f4b624ddb5c8dec06c3b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 15 Feb 2017 09:02:47 +0800 Subject: [PATCH 032/264] Fix typo. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index e5e446a..e8d0d00 100644 --- a/upgrade.md +++ b/upgrade.md @@ -2,7 +2,7 @@ ## Upgrading from v6.x to v7.x -To upgrade Laravel Datatable from version 6.x to version 7.x: +To upgrade Laravel Datatables from version 6.x to version 7.x: ```sh composer require yajra/laravel-datatables-oracle:^7.0 From dae86fe5c34f7dd52fb580832e6b403e485eb618 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 16 Feb 2017 14:44:06 +0800 Subject: [PATCH 033/264] Update buttons console and installation docs. --- buttons-console.md | 90 ++++++++++++++++++++++++++++++++++++++--- buttons-installation.md | 2 +- 2 files changed, 85 insertions(+), 7 deletions(-) diff --git a/buttons-console.md b/buttons-console.md index 4c6b453..13589bb 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -29,16 +29,15 @@ use Yajra\Datatables\Services\DataTable; class PostsDataTable extends DataTable { /** - * Display ajax response. + * Build DataTable class. * - * @return \Illuminate\Http\JsonResponse + * @return \Yajra\Datatables\Engines\BaseEngine */ - public function ajax() + public function dataTable() { return $this->datatables ->eloquent($this->query()) - ->addColumn('action', 'path.to.action.view') - ->make(true); + ->addColumn('action', 'path.to.action.view'); } /** @@ -99,9 +98,88 @@ class PostsDataTable extends DataTable In this example, we will pass a `--model` option to set the model to be used by our DataTable. ``` -php artisan datatables:make PostsDataTable --model=Post +php artisan datatables:make Posts --model ``` +This will generate a `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. +The exported filename will also be set to `posts_(timestamp)`. + +```php +datatables + ->eloquent($this->query()) + ->addColumn('action', 'path.to.action.view'); + } + + /** + * Get the query object to be processed by dataTables. + * + * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection + */ + public function query() + { + $query = Post::query(); + + return $this->applyScopes($query); + } + + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\Datatables\Html\Builder + */ + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->ajax('') + ->addAction(['width' => '80px']) + ->parameters($this->getBuilderParameters()); + } + + /** + * Get columns. + * + * @return array + */ + protected function getColumns() + { + return [ + 'id', + // add your columns + 'created_at', + 'updated_at', + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename() + { + return 'posts_' . time(); + } +} +``` + + ## Creating a DataTable Scope service class DataTable scope is class that we can use to limit our database search results based on the defined query scopes. diff --git a/buttons-installation.md b/buttons-installation.md index 86f48c9..5d08047 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^1.0` +`composer require yajra/laravel-datatables-buttons:^1.1` Open the file ```config/app.php``` and then add following service provider. From f5b8f4813fce261939a6082e36c9785b3159e06f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 16 Feb 2017 14:50:54 +0800 Subject: [PATCH 034/264] Add extended DataTable docs. --- buttons-extended.md | 17 +++++++++++++++++ documentation.md | 1 + 2 files changed, 18 insertions(+) create mode 100644 buttons-extended.md diff --git a/buttons-extended.md b/buttons-extended.md new file mode 100644 index 0000000..6045b1d --- /dev/null +++ b/buttons-extended.md @@ -0,0 +1,17 @@ +# Extended DataTable + +We can now extend and reuse our DataTable class inside our controller by using `before` and `response` callback. + +## Quick Example: +```php +Route::get('datatable', function(RolesDataTable $dataTable){ + return $dataTable->before(function (Yajra\Datatables\Engines\BaseEngine $dataTable) { + return $dataTable->addColumn('test', 'added inside controller'); + })->response(function (Illuminate\Support\Collection $response) { + $response['test'] = 'Append Data'; + + return $response; + })->render('path.to.view'); +}); +``` + diff --git a/documentation.md b/documentation.md index 7c8a146..0f37ef4 100644 --- a/documentation.md +++ b/documentation.md @@ -77,6 +77,7 @@ - [Configuration](/docs/{{package}}/{{version}}/buttons-config) - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) + - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) From 747fa9d05e28f7b0b7f491662b346cf31564e6ae Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 16 Feb 2017 14:58:45 +0800 Subject: [PATCH 035/264] Add upgrade guide. --- buttons-extended.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/buttons-extended.md b/buttons-extended.md index 6045b1d..7524e13 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -2,6 +2,36 @@ We can now extend and reuse our DataTable class inside our controller by using `before` and `response` callback. +> IMPORTANT: Extended DataTable is only applicable on `^1.1` and above. + + +## Upgrading from v1.0 to v1.1 +- Upgrade to `laravel-datatables-buttons:^1.1` +- Rename `ajax()` method to `dataTable()` +- Remove `->make(true)` from the method chain. + +```php + public function ajax() + { + return $this->datatables + ->eloquent($this->query()) + ->addColumn('action', 'path.to.action.view') + ->make(true) + } +``` + +TO + + +```php + public function dataTable() + { + return $this->datatables + ->eloquent($this->query()) + ->addColumn('action', 'path.to.action.view'); + } +``` + ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ @@ -14,4 +44,3 @@ Route::get('datatable', function(RolesDataTable $dataTable){ })->render('path.to.view'); }); ``` - From 9880e8f984ca6800c92c5d984662ea30c0119072 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 16 Feb 2017 15:02:31 +0800 Subject: [PATCH 036/264] Add only trashed docs. --- documentation.md | 1 + only-trashed.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 only-trashed.md diff --git a/documentation.md b/documentation.md index 0f37ef4..c9d3de8 100644 --- a/documentation.md +++ b/documentation.md @@ -55,6 +55,7 @@ - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) - [With Trashed](/docs/{{package}}/{{version}}/with-trashed) + - [Only Trashed](/docs/{{package}}/{{version}}/only-trashed) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) ### PLUGINS diff --git a/only-trashed.md b/only-trashed.md new file mode 100644 index 0000000..fbbed15 --- /dev/null +++ b/only-trashed.md @@ -0,0 +1,16 @@ +# Eloquent Model With Only Trashed + +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include only trashed records in the results. +To achieve this, we can use `onlyTrashed` api. + +```php +use Datatables; + +Route::get('user-data', function() { + $model = App\User::onlyTrashed()->query(); + + return Datatables::eloquent($model) + ->onlyTrashed() + ->make(true); +}); +``` \ No newline at end of file From 598c1b01ed77b2c40f8ab29edb3e77c72068400d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Feb 2017 18:08:02 +0800 Subject: [PATCH 037/264] Fix typo. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index e8d0d00..1762bf4 100644 --- a/upgrade.md +++ b/upgrade.md @@ -16,7 +16,7 @@ Service class is now extracted to own plugin, `Buttons Plugin`. If you are using composer require yajra/laravel-datatables-buttons:^1.0 ``` -Register `Yajra\Datatables\ButtonsServiceProder::class` on `config/app.php` and publish config. +Register `Yajra\Datatables\ButtonsServiceProvider::class` on `config/app.php` and publish config. ```php From b8de63fa0ac0927a85a6fb4677bf8838669f7d60 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 2 Mar 2017 08:30:28 +0800 Subject: [PATCH 038/264] Update fractal docs. Fix https://github.com/yajra/laravel-datatables/issues/1038. --- response-fractal.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/response-fractal.md b/response-fractal.md index 296c32c..6b015e3 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -1,6 +1,7 @@ # Response using Transformer -When using tranformer, all column operations must be done via transformer. Thus `addColumn`, `editColumn` and `removeColumn` should be avoided when using fractal. +When using tranformer, all response manipulations must be done via transformer. +Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, etc... should be avoided when using fractal. ```php use Datatables; From c4ec80793c6da6e791da27a9d50dc170455d1edc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 28 Mar 2017 13:33:54 +0800 Subject: [PATCH 039/264] Add withHtml builder callback. --- buttons-extended.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buttons-extended.md b/buttons-extended.md index 7524e13..a5ce0bb 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -35,12 +35,14 @@ TO ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ - return $dataTable->before(function (Yajra\Datatables\Engines\BaseEngine $dataTable) { + return $dataTable->before(function (\Yajra\Datatables\Engines\BaseEngine $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); - })->response(function (Illuminate\Support\Collection $response) { + })->response(function (\Illuminate\Support\Collection $response) { $response['test'] = 'Append Data'; return $response; + })->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { + $builder->columns(['id', 'name', 'etc...']); })->render('path.to.view'); }); ``` From 70427ed0a1edff716be53edcd22aa57dd73b7cd0 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 28 Mar 2017 13:36:41 +0800 Subject: [PATCH 040/264] Add fluent dataTable variable setter. --- buttons-extended.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/buttons-extended.md b/buttons-extended.md index a5ce0bb..abd364f 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -37,12 +37,20 @@ TO Route::get('datatable', function(RolesDataTable $dataTable){ return $dataTable->before(function (\Yajra\Datatables\Engines\BaseEngine $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); - })->response(function (\Illuminate\Support\Collection $response) { + }) + ->response(function (\Illuminate\Support\Collection $response) { $response['test'] = 'Append Data'; return $response; - })->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { + }) + ->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { $builder->columns(['id', 'name', 'etc...']); - })->render('path.to.view'); + }) + ->with('key', 'value') + ->with([ + 'key2' => 'value2', + 'key3' => 'value3', + ]) + ->render('path.to.view'); }); ``` From 5ec693f28f240bad37de97a35fcb83e74792121f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 28 Mar 2017 15:21:33 +0800 Subject: [PATCH 041/264] Fix with trashed query. Fix https://github.com/yajra/laravel-datatables/issues/1079. --- with-trashed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/with-trashed.md b/with-trashed.md index f3efb1a..64c1aee 100644 --- a/with-trashed.md +++ b/with-trashed.md @@ -7,7 +7,7 @@ To achieve this, we can use `withTrashed` api. use Datatables; Route::get('user-data', function() { - $model = App\User::withTrashed()->query(); + $model = App\User::query()->withTrashed(); return Datatables::eloquent($model) ->withTrashed() From f799f614da4d5573e829985de875cb7e2790ba1b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 12 Apr 2017 16:12:15 +0800 Subject: [PATCH 042/264] Add xss rawColumns api. --- xss.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/xss.md b/xss.md index d1ea985..56792a5 100644 --- a/xss.md +++ b/xss.md @@ -1,6 +1,19 @@ # XSS filtering -To prevent XSS attack on some of your columns, you can use `escapeColumns` api. +Since v7.0, all dataTable response are encoded to prevent XSS attack. In case you need to display html on your columns, you can use `rawColumns` api. + +> `action` column is allowed as raw by default. + + + +## Raw Columns +```php +return Datatables::eloquent(Role::select()) + ->rawColumns(['name', 'action']) + ->make(true); +``` + +# Other XSS methods ## Escape selected fields From 61a9fd6714470ffc3b6d6d735a3ad529b4e0b2de Mon Sep 17 00:00:00 2001 From: underdpt Date: Thu, 20 Apr 2017 08:57:07 +0200 Subject: [PATCH 043/264] Custom button actions documentation --- buttons-custom.md | 38 ++++++++++++++++++++++++++++++++++++++ documentation.md | 1 + 2 files changed, 39 insertions(+) create mode 100644 buttons-custom.md diff --git a/buttons-custom.md b/buttons-custom.md new file mode 100644 index 0000000..bd333ce --- /dev/null +++ b/buttons-custom.md @@ -0,0 +1,38 @@ +# Custom Actions + +You can enable custom actions on your buttons, as follows: + +Update `UsersDataTable` class and overload the `actions` property. Here we are +disabling the `csv` and `pdf` action (so they cannot be fired by hijacking the +request) and enabling a `myCustomAction`. + + +```php +namespace App\DataTables; + +use App\User; +use Yajra\Datatables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + protected $actions = ['print', 'excel', 'myCustomAction']; + + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->parameters([ + 'dom' => 'Bfrtip', + 'buttons' => ['print', 'excel', 'myCustomAction'], + ]); + } + + public function myCustomAction() + { + //...your code here. + } + +} +``` + +Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). diff --git a/documentation.md b/documentation.md index c9d3de8..941da1f 100644 --- a/documentation.md +++ b/documentation.md @@ -78,6 +78,7 @@ - [Configuration](/docs/{{package}}/{{version}}/buttons-config) - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) + - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) From aba4cd99e7c6a7f502f0f9e8e77680276f31f2ed Mon Sep 17 00:00:00 2001 From: underdpt Date: Thu, 20 Apr 2017 09:46:50 +0200 Subject: [PATCH 044/264] Update buttons-custom.md --- buttons-custom.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-custom.md b/buttons-custom.md index bd333ce..42e7905 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -15,7 +15,7 @@ use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { - protected $actions = ['print', 'excel', 'myCustomAction']; + protected $actions = ['print', 'excel', 'myCustomAction']; public function html() { From 78fce7d853d2b7951da7881b58785f68cc3c6e0b Mon Sep 17 00:00:00 2001 From: Mathias E Date: Fri, 21 Apr 2017 14:14:48 +0200 Subject: [PATCH 045/264] Update buttons-console documentation PR #12 Add new options added in PR #12 on yajra/laravel-datatables-buttons --- buttons-console.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/buttons-console.md b/buttons-console.md index 13589bb..702d9a2 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -180,6 +180,38 @@ class PostsDataTable extends DataTable ``` +### Model Namespace Option + +In this example, we will pass a `--model-namespace` option to set the model namespace to be used by our DataTable. + +``` +php artisan datatables:make Posts --model-namespace="Models\Client" +``` +It will implicitly activate `--model` option and override the `model` parameter in `datatables-buttons` config file. +This will allow to use a non-standard namespace if front-end and back-end models are in separate namespace for example. + + + +### Action Option + +In this example, we will pass a `--action` option to set a custom path for the action column view. + +``` +php artisan datatables:make Posts --action="client.action" +``` +If not provided, a default path will be used. It will needs to be changed thereafter. + +### Columns Option + +In this example, we will pass a `--columns` option to set the columns to be used by our DataTable. + +``` +php artisan datatables:make Posts --columns="id,title,author" +``` +If not provided, a default set of columns will be used. It will needs to be manually changed thereafter. + + + ## Creating a DataTable Scope service class DataTable scope is class that we can use to limit our database search results based on the defined query scopes. @@ -208,4 +240,4 @@ class ActiveUser implements DataTableScopeContract return $query->where('active', true); } } -``` \ No newline at end of file +``` From d08484da8465ae1c6c70dcb439d906fb5ae5138b Mon Sep 17 00:00:00 2001 From: Alfa Adhitya Date: Fri, 19 May 2017 16:50:24 +0700 Subject: [PATCH 046/264] fix typo --- raw-columns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raw-columns.md b/raw-columns.md index e612e3f..d8f45ce 100644 --- a/raw-columns.md +++ b/raw-columns.md @@ -1,6 +1,6 @@ # Raw Columns -By default, Laravel DataTables protects us from XSS attack by esacping all our outputs. +By default, Laravel DataTables protects us from XSS attack by escaping all our outputs. In cases where you want to render an html content, please use `rawColumns` api. From 7bdc9acdaa2e7779e2f5f94ce6e740c19bf7be63 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 22 May 2017 11:30:39 +0800 Subject: [PATCH 047/264] Add error handler docs. --- documentation.md | 1 + error-handler.md | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 error-handler.md diff --git a/documentation.md b/documentation.md index 941da1f..6ba44ef 100644 --- a/documentation.md +++ b/documentation.md @@ -15,6 +15,7 @@ - Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) + - [Error Handler](/docs/{{package}}/{{version}}/error-handler) - Engines & Data Sources - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) - [Query Builder](/docs/{{package}}/{{version}}/engine-query) diff --git a/error-handler.md b/error-handler.md new file mode 100644 index 0000000..40f0721 --- /dev/null +++ b/error-handler.md @@ -0,0 +1,76 @@ +# Error Handler + +Laravel DataTables allows you to configure how you want to handle server-side errors when processing your request. +Below are the options available for error handling. + +## ERROR CONFIGURATIONS +Configuration is located at `config/datatables.php` under `error` key. + + +- [NULL](#null-error) : `'error' => null` +- [THROW](#throw-error) : `'error' => 'throw'` +- [CUSTOM MESSAGE](#custom-message) : `'error' => 'Any custom friendly message'` +- [TRANSLATION](#custom-message) : `'error' => 'translation.key'` + + +## NULL Error +If set to `null`, the actual exception message will be used on error response. + +```json +{ + "draw": 24, + "recordsTotal": 200, + "recordsFiltered": 0, + "data": [], + "error": "Exception Message:\n\nSQLSTATE[42S22]: Column not found: 1054 Unknown column 'xxx' in 'order clause' (SQL: select * from `users` where `users`.`deleted_at` is null order by `xxx` asc limit 10 offset 0)" +} +``` + + +## THROW Error +If set to `'throw'`, the package will throw a `\Yajra\Datatables\Exception`. +You can then use your custom error handler if needed. + +**Example Error Handler** + +Update `app\Exceptions\Handler.php` and register dataTables error exception handler. + +```php + /** + * Render an exception into an HTTP response. + * + * @param \Illuminate\Http\Request $request + * @param \Exception $exception + * @return \Illuminate\Http\Response + */ + public function render($request, Exception $exception) + { + if ($exception instanceof \Yajra\Datatables\Exception) { + return response([ + 'draw' => 0, + 'recordsTotal' => 0, + 'recordsFiltered' => 0, + 'data' => [], + 'error' => 'Laravel Error Handler', + ]); + } + + return parent::render($request, $exception); + } +``` + + +## Custom Message +If set to `'any custom message'` or `'translation.key'`, this message will be used when an error occurs when processing the request. + +```json +{ + "draw": 24, + "recordsTotal": 200, + "recordsFiltered": 0, + "data": [], + "error": "any custom message" +} +``` + + From 72f1d3e0b6ae3d84c46b57fc63fd06e2630a36fd Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 22 May 2017 11:43:34 +0800 Subject: [PATCH 048/264] Update debugger docs and add env config. --- debugger.md | 4 +++- error-handler.md | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/debugger.md b/debugger.md index 0c1e87c..25b6dd4 100644 --- a/debugger.md +++ b/debugger.md @@ -1,9 +1,11 @@ # Debugging Mode -To enable debugging mode, just set ```APP_DEBUG=true``` and the package will include the queries and inputs used when processing the table. +To enable debugging mode, just set `APP_DEBUG=true` and the package will include the queries and inputs used when processing the table. > IMPORTANT: Please make sure that APP_DEBUG is set to false when your app is on production. +You also need to update the [Error Handler](/docs/{{package}}/{{version}}/error-handler) config appropriately. + ## Example Response ```json { diff --git a/error-handler.md b/error-handler.md index 40f0721..4d812de 100644 --- a/error-handler.md +++ b/error-handler.md @@ -4,7 +4,10 @@ Laravel DataTables allows you to configure how you want to handle server-side er Below are the options available for error handling. ## ERROR CONFIGURATIONS -Configuration is located at `config/datatables.php` under `error` key. +Configuration is located at `config/datatables.php` under `error` key. +You can also configure via env by setting `DATATABLES_ERROR` key appropriately. + +The default configuration is `env('DATATABLES_ERROR', null)`. - [NULL](#null-error) : `'error' => null` From f14c27d900ada0004064d94927386467758f614d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 30 May 2017 14:42:04 +0800 Subject: [PATCH 049/264] Add docs for sending parameters from controller to dataTable class. --- buttons-with.md | 26 ++++++++++++++++++++++++++ documentation.md | 1 + 2 files changed, 27 insertions(+) create mode 100644 buttons-with.md diff --git a/buttons-with.md b/buttons-with.md new file mode 100644 index 0000000..b872b19 --- /dev/null +++ b/buttons-with.md @@ -0,0 +1,26 @@ +# Sending parameter to DataTable class +You can send a parameter from controller to dataTable class using `with` api. + + +## Example: + +```php +Route::get('datatable/{id}', function(UsersDataTable $dataTable, $id){ + return $dataTable->with('id', $id) + ->with([ + 'key2' => 'value2', + 'key3' => 'value3', + ]) + ->render('path.to.view'); +}); +``` + +You can then get the variable as a local property of the class. + +```php +class UsersDataTable { + public function query() { + return User::where('id', $this->id); + } +} +``` diff --git a/documentation.md b/documentation.md index 6ba44ef..a8263cb 100644 --- a/documentation.md +++ b/documentation.md @@ -80,6 +80,7 @@ - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) + - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) From 71ff691cabb48c1bc103572ee6c47c3b9b27456f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:08:30 +0800 Subject: [PATCH 050/264] Add html builder macro docs. --- documentation.md | 1 + html-builder-macro.md | 31 +++++++++++++++++++++++++++++++ html-installation.md | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 html-builder-macro.md diff --git a/documentation.md b/documentation.md index a8263cb..36eec7c 100644 --- a/documentation.md +++ b/documentation.md @@ -66,6 +66,7 @@ - [Builder](/docs/{{package}}/{{version}}/html-builder) - [Table](/docs/{{package}}/{{version}}/html-builder-table) - [Columns](/docs/{{package}}/{{version}}/html-builder-column) + - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) diff --git a/html-builder-macro.md b/html-builder-macro.md new file mode 100644 index 0000000..52fcb5a --- /dev/null +++ b/html-builder-macro.md @@ -0,0 +1,31 @@ +# Html Builder Macro + +You can extend DataTables HTML Builder using `macro`. + +## Example macro: +```php +use Yajra\Datatables\Html\Builder; +use Yajra\Datatables\Html\Column; + +Builder::macro('addEditColumn', function () { + $attributes = [ + 'title' => 'Edit', + 'data' => 'edit', + 'name' => '', + 'orderable' => false, + 'searchable' => false, + ]; + + $this->collection->push(new Column($attributes)); + + return $this; +}); + +``` + +## Usage +```php +$builder = new Builder; +$builder->addEditColumn()->ajax()->parameters([]); + +``` \ No newline at end of file diff --git a/html-installation.md b/html-installation.md index 8af414d..d8061b1 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,7 +4,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^1.0` +`composer require yajra/laravel-datatables-html:^2.0` Open the file ```config/app.php``` and then add following service provider. From dc35856cf976f4b30b41ff0499dafde355befa6a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:14:30 +0800 Subject: [PATCH 051/264] Add html builder config docs. --- documentation.md | 1 + html-builder-config.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 html-builder-config.md diff --git a/documentation.md b/documentation.md index 36eec7c..18620f6 100644 --- a/documentation.md +++ b/documentation.md @@ -65,6 +65,7 @@ - [Installation](/docs/{{package}}/{{version}}/html-installation) - [Builder](/docs/{{package}}/{{version}}/html-builder) - [Table](/docs/{{package}}/{{version}}/html-builder-table) + - [Config](/docs/{{package}}/{{version}}/html-builder-config) - [Columns](/docs/{{package}}/{{version}}/html-builder-column) - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) diff --git a/html-builder-config.md b/html-builder-config.md new file mode 100644 index 0000000..b851797 --- /dev/null +++ b/html-builder-config.md @@ -0,0 +1,16 @@ +# Html Builder Config + +Default table attributes are now configurable. +To begin, you need to publish the config by running `php artisan vendor:publish --tag=datatables-html` + +Published config is located at `config/datatables-html.php`. +You can then update the default table attributes that you prefer for every table rendered using the builder class. + +```php +return [ + 'table' => [ + 'class' => 'table', + 'id' => 'dataTableId' + ] +]; +``` \ No newline at end of file From 2bbf9574891cc21315cc2220351f0aff4096c62d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:24:03 +0800 Subject: [PATCH 052/264] Add minified ajax docs. --- documentation.md | 1 + html-builder-minified-ajax.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 html-builder-minified-ajax.md diff --git a/documentation.md b/documentation.md index 18620f6..5801f76 100644 --- a/documentation.md +++ b/documentation.md @@ -69,6 +69,7 @@ - [Columns](/docs/{{package}}/{{version}}/html-builder-column) - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) + - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) diff --git a/html-builder-minified-ajax.md b/html-builder-minified-ajax.md new file mode 100644 index 0000000..cb91056 --- /dev/null +++ b/html-builder-minified-ajax.md @@ -0,0 +1,23 @@ +# Html Builder Minified Ajax + +Ajax is an option that you set to tell `dataTable` where to fetch it's data. +But unlike the regular ajax method, `minifiedAjax` minifies the url generated by dataTables by removing any unnecessary query parameters thus shortening the url +from approx 1500 url length down to 500. +Shortening the URL will help us prevent any browser and development issues concerning the URL length existing the max allowed value. + + +**Syntax** +```php +$builder->minifiedAjax($url, $script = '', $data = []); +``` + +## Ajax Parameters +`$url` is the url where we will fetch our json data. +`$script` any vanilla javascript to be included on `data` method of ajax. +`$data` is an array of values to be appended on server request. + +```php +$builder->minifiedAjax('', null, ['foo' => 'bar']) +``` + + From 34329112f10ff157cef9a725c7cefd46040dd07a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:24:55 +0800 Subject: [PATCH 053/264] Fix spacing. --- html-builder-minified-ajax.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html-builder-minified-ajax.md b/html-builder-minified-ajax.md index cb91056..4d26f5d 100644 --- a/html-builder-minified-ajax.md +++ b/html-builder-minified-ajax.md @@ -13,9 +13,12 @@ $builder->minifiedAjax($url, $script = '', $data = []); ## Ajax Parameters `$url` is the url where we will fetch our json data. + `$script` any vanilla javascript to be included on `data` method of ajax. + `$data` is an array of values to be appended on server request. + ```php $builder->minifiedAjax('', null, ['foo' => 'bar']) ``` From 14a10c75469441677bb801400fafcdb63f4d3fa0 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:26:06 +0800 Subject: [PATCH 054/264] Fix typo. --- html-builder-minified-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-minified-ajax.md b/html-builder-minified-ajax.md index 4d26f5d..20a529e 100644 --- a/html-builder-minified-ajax.md +++ b/html-builder-minified-ajax.md @@ -3,7 +3,7 @@ Ajax is an option that you set to tell `dataTable` where to fetch it's data. But unlike the regular ajax method, `minifiedAjax` minifies the url generated by dataTables by removing any unnecessary query parameters thus shortening the url from approx 1500 url length down to 500. -Shortening the URL will help us prevent any browser and development issues concerning the URL length existing the max allowed value. +Shortening the URL will help us prevent any browser and development issues concerning the URL length exceeding the max allowed value. **Syntax** From 329691fdf6d6dc1b470e009454fc7dddc5c60e27 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 28 Jun 2017 14:37:55 +0800 Subject: [PATCH 055/264] Use buttons 2.0 --- buttons-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-installation.md b/buttons-installation.md index 5d08047..23d3e02 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^1.1` +`composer require yajra/laravel-datatables-buttons:^2.0` Open the file ```config/app.php``` and then add following service provider. From 8546a641832ced2fcb5e51a9f468f64270eaddca Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 5 Jul 2017 16:45:06 +0800 Subject: [PATCH 056/264] Add version 8 upgrade guide. --- upgrade.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 1762bf4..25e92de 100644 --- a/upgrade.md +++ b/upgrade.md @@ -1,5 +1,85 @@ # Upgrade Guide + +## Upgrading from v7.x to v8.x +To upgrade Laravel Datatables from version 7.x to version 8.x: + + +```bash +composer require yajra/laravel-datatables-oracle:8.* +php artisan vendor:publish --tag=datatables --force +``` + +If you are using service approach: +```bash +composer require yajra/laravel-datatables-buttons:3.* +php artisan vendor:publish --tag=datatables-buttons --force +``` + +If you are using fractal: +```bash +composer require yajra/laravel-datatables-fractal:1.* +php artisan vendor:publish --tag=datatables-fractal --force +``` + + +## [v8] Namespace +The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +> Use sublime's find and replace all feature to update all affected files. + + +## [v8] Facade +DataTables Facade was renamed to `Yajra\DataTables\Facades\DataTables`. If you want to continue using your old facade, just register the alias on your `config/app.php` file. + +```php +'Datatables' => Yajra\DataTables\Facades\DataTables::class +``` + + +## [v8] DataTables Factory class +DataTables factory class is now renamed to `Factory` from `Datatables`. If you are injecting `Yajra\Datatables\Datables` on your code, you must update it to `Yajra\DataTables\Factory`. + +`Datatables::of()` method is deprecated in favor of `Factory::make()` to match Laravel's factory api. `of` api will be removed on next major release. + + +## [v8] DataTables Buttons Changes +- The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +> Use sublime's find and replace all feature to update all affected files. +- Constructor dependencies were removed. +- `dataTable()` method is now strictly implemented. +- You need to instanstiate the DataTable class within the `dataTable()` method: +```php +// FROM +public function dataTable() { + return $this->datatables->eloquent($this->query()); +} +``` +```php +// TO +use Yajra\DataTables\EloquentDataTable; +public function dataTable() { + return new EloquentDataTable($this->query()); +} +``` + + +## [v8] DataTables Html Changes +The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +> Use sublime's find and replace all feature to update all affected files. + + +## [v8] DataTables Trashed +DataTables now supports `SoftDeletes` hence, there is no need to use `withTrashed` and `onlyTrashed`. + + + +## [v8] Functionalities Removed +- Removed `filterColumn` api magic query method in favor of closure. +- Removed support on older `snake_case` methods. +- Removed silly implementation of proxying query builder calls via magic method. +- Removed unused methods. +- Removed `withTrashed` and `onlyTrashed` api. + ## Upgrading from v6.x to v7.x To upgrade Laravel Datatables from version 6.x to version 7.x: @@ -26,7 +106,7 @@ php artisan vendor:publish --tag=datatables-buttons --force ### Html Builder HTML builder is now extracted to own plugin, If you are using Datatables html builder, you need to perform the following: -> {info} HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. +> HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. ```sh composer require yajra/laravel-datatables-html:^1.0 From e8d37fd3825c9376ac3798cdc6e849584c510140 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 5 Jul 2017 16:52:55 +0800 Subject: [PATCH 057/264] Fix typo. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 25e92de..d73b3b9 100644 --- a/upgrade.md +++ b/upgrade.md @@ -2,7 +2,7 @@ ## Upgrading from v7.x to v8.x -To upgrade Laravel Datatables from version 7.x to version 8.x: +To upgrade Laravel DataTables from version 7.x to version 8.x: ```bash From 2f3d7bcab26322ba60f933fba572a743f7d73589 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 5 Jul 2017 16:53:59 +0800 Subject: [PATCH 058/264] Add html plugin upgrade notes. --- upgrade.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index d73b3b9..f72b299 100644 --- a/upgrade.md +++ b/upgrade.md @@ -10,12 +10,18 @@ composer require yajra/laravel-datatables-oracle:8.* php artisan vendor:publish --tag=datatables --force ``` -If you are using service approach: +If you are using service approach / buttons plugin: ```bash composer require yajra/laravel-datatables-buttons:3.* php artisan vendor:publish --tag=datatables-buttons --force ``` +If you are using html plugin: +```bash +composer require yajra/laravel-datatables-html:3.* +php artisan vendor:publish --tag=datatables-html --force +``` + If you are using fractal: ```bash composer require yajra/laravel-datatables-fractal:1.* From c3b31fb25d94aab7db78f7cf9eb7c185432ed912 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 6 Jul 2017 12:54:19 +0800 Subject: [PATCH 059/264] Update buttons plugin upgrade docs. --- upgrade.md | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/upgrade.md b/upgrade.md index f72b299..65c7dff 100644 --- a/upgrade.md +++ b/upgrade.md @@ -52,21 +52,45 @@ DataTables factory class is now renamed to `Factory` from `Datatables`. If you a - The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. - Constructor dependencies were removed. -- `dataTable()` method is now strictly implemented. - You need to instanstiate the DataTable class within the `dataTable()` method: -```php -// FROM -public function dataTable() { + ```php + // FROM + public function dataTable() { return $this->datatables->eloquent($this->query()); -} -``` -```php -// TO -use Yajra\DataTables\EloquentDataTable; -public function dataTable() { - return new EloquentDataTable($this->query()); -} -``` + } + ``` + ```php + // TO + use Yajra\DataTables\EloquentDataTable; + public function dataTable($query) { + return new EloquentDataTable($query); + } + ``` + + Or inject the factory using method injection. + ```php + use Yajra\DataTables\Factory; + public function dataTable($query, Factory $dataTable) { + return $dataTable->eloquent($query); + } + ``` +- Query method results are automatically injected on `dataTable($query)` api. + ```php + use Yajra\DataTables\Factory; + public function dataTable($query, Factory $dataTable) { + return $dataTable->eloquent($query); + } + + public function query() { + return Model::query(); + } + ``` +- The following methods now supports method injection: + + Action Buttons: `csv(), pdf(), excel(), printPreview()` + + Builder Methods: `ajax(), dataTable(), query()` + ## [v8] DataTables Html Changes From 0552574fc500974bad4f0094fc8035f12dd02534 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 6 Jul 2017 17:44:48 +0800 Subject: [PATCH 060/264] Use DataTables instead of Factory. --- upgrade.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade.md b/upgrade.md index 65c7dff..1c164cb 100644 --- a/upgrade.md +++ b/upgrade.md @@ -43,9 +43,9 @@ DataTables Facade was renamed to `Yajra\DataTables\Facades\DataTables`. If you w ## [v8] DataTables Factory class -DataTables factory class is now renamed to `Factory` from `Datatables`. If you are injecting `Yajra\Datatables\Datables` on your code, you must update it to `Yajra\DataTables\Factory`. +DataTables factory class is now renamed to `DataTables` from `Datatables`. If you are injecting `Yajra\Datatables\Datables` on your code, you must update it to `Yajra\DataTables\DataTables`. -`Datatables::of()` method is deprecated in favor of `Factory::make()` to match Laravel's factory api. `of` api will be removed on next major release. +`DataTables::of()` method is now an alias of new `DataTables::make()` method to match Laravel's factory api structure. ## [v8] DataTables Buttons Changes From dd7c5f9ce380a2c1336c36d9220f0690c1c79cd5 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 6 Jul 2017 17:46:03 +0800 Subject: [PATCH 061/264] Fix typo. --- upgrade.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/upgrade.md b/upgrade.md index 1c164cb..d55a9d2 100644 --- a/upgrade.md +++ b/upgrade.md @@ -43,7 +43,7 @@ DataTables Facade was renamed to `Yajra\DataTables\Facades\DataTables`. If you w ## [v8] DataTables Factory class -DataTables factory class is now renamed to `DataTables` from `Datatables`. If you are injecting `Yajra\Datatables\Datables` on your code, you must update it to `Yajra\DataTables\DataTables`. +DataTables factory class is now renamed to `DataTables` from `Datatables`. If you are injecting `Yajra\Datatables\Datatables` on your code, you must update it to `Yajra\DataTables\DataTables`. `DataTables::of()` method is now an alias of new `DataTables::make()` method to match Laravel's factory api structure. From 714a99afca35205049aac7e5ce02a3085abea574 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 6 Jul 2017 18:35:14 +0800 Subject: [PATCH 062/264] Fix factory. --- upgrade.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/upgrade.md b/upgrade.md index d55a9d2..8797438 100644 --- a/upgrade.md +++ b/upgrade.md @@ -69,16 +69,16 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo Or inject the factory using method injection. ```php - use Yajra\DataTables\Factory; - public function dataTable($query, Factory $dataTable) { - return $dataTable->eloquent($query); + use Yajra\DataTables\DataTables; + public function dataTable($query, DataTables $dataTables) { + return $dataTables->eloquent($query); } ``` - Query method results are automatically injected on `dataTable($query)` api. ```php - use Yajra\DataTables\Factory; - public function dataTable($query, Factory $dataTable) { - return $dataTable->eloquent($query); + use Yajra\DataTables\DataTables; + public function dataTable($query, DataTables $dataTables) { + return $dataTables->eloquent($query); } public function query() { From 1bed56efe068314322b20f5e525d73e79b0ec64d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 21 Jul 2017 10:23:58 +0800 Subject: [PATCH 063/264] Add link to buttons changelog. --- upgrade.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/upgrade.md b/upgrade.md index 8797438..9cd1a92 100644 --- a/upgrade.md +++ b/upgrade.md @@ -49,6 +49,8 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo ## [v8] DataTables Buttons Changes +> See https://github.com/yajra/laravel-datatables-buttons/blob/master/CHANGELOG.md for full changelog. + - The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. - Constructor dependencies were removed. @@ -91,6 +93,10 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo Builder Methods: `ajax(), dataTable(), query()` +- `DataTableContract` contract removed. +- `DataTableScopeContract` contract renamed to `DataTableScope`. +- `DataTableButtonsContract` contract renamed to `DataTableButtons`. + ## [v8] DataTables Html Changes From f1f573fe74064b744fc7dc149bfac1d40aa81af0 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 31 Aug 2017 16:32:49 +0800 Subject: [PATCH 064/264] Update docs. Fix https://github.com/yajra/laravel-datatables/issues/1352 --- upgrade.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upgrade.md b/upgrade.md index 9cd1a92..7c64fe7 100644 --- a/upgrade.md +++ b/upgrade.md @@ -69,10 +69,10 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo } ``` - Or inject the factory using method injection. + Or inject the factory using method injection. Note that you need to inject your classes first before the query results. ```php use Yajra\DataTables\DataTables; - public function dataTable($query, DataTables $dataTables) { + public function dataTable(DataTables $dataTables, $query) { return $dataTables->eloquent($query); } ``` From 1da183c71286b8235a2bbbadf15e842389a89251 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 1 Sep 2017 08:56:50 +0800 Subject: [PATCH 065/264] Note that dataTable method should be public. --- upgrade.md | 1 + 1 file changed, 1 insertion(+) diff --git a/upgrade.md b/upgrade.md index 7c64fe7..2fbea02 100644 --- a/upgrade.md +++ b/upgrade.md @@ -55,6 +55,7 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo > Use sublime's find and replace all feature to update all affected files. - Constructor dependencies were removed. - You need to instanstiate the DataTable class within the `dataTable()` method: +- The `dataTable()` method should `public` now instead of `protected`. ```php // FROM public function dataTable() { From 46d912e0a333461523929151b42ad16eab08cf36 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:35:00 +0800 Subject: [PATCH 066/264] Rename Datatables to DataTables. --- add-column.md | 20 +++++----- blacklist.md | 6 +-- buttons-config.md | 6 +-- buttons-console.md | 38 +++++++++--------- buttons-custom.md | 4 +- buttons-export.md | 14 +++---- buttons-extended.md | 10 ++--- buttons-installation.md | 8 ++-- buttons-starter.md | 12 +++--- contributing.md | 4 +- documentation.md | 10 ++--- edit-column.md | 16 ++++---- engine-collection.md | 20 +++++----- engine-eloquent.md | 20 +++++----- engine-query.md | 20 +++++----- error-handler.md | 12 +++--- filter-column.md | 4 +- general-settings.md | 16 ++++---- html-builder-ajax.md | 6 +-- html-builder-callbacks.md | 4 +- html-builder-checkbox.md | 4 +- html-builder-column.md | 6 +-- html-builder-config.md | 6 +-- html-builder-index.md | 2 +- html-builder-macro.md | 6 +-- html-builder-minified-ajax.md | 2 +- html-builder-parameters.md | 6 +-- html-builder-table.md | 6 +-- html-builder.md | 20 +++++----- html-installation.md | 8 ++-- index-column.md | 6 +-- installation.md | 16 ++++---- introduction.md | 18 ++++----- manual-order.md | 8 ++-- manual-search.md | 8 ++-- only-trashed.md | 8 ++-- order-by-nulls-last.md | 6 +-- order-column.md | 6 +-- order-columns.md | 6 +-- query-builder.md | 8 ++-- raw-columns.md | 4 +- readme.md | 6 +-- regex.md | 4 +- relationships.md | 6 +-- releases.md | 12 +++--- remove-column.md | 4 +- response-array.md | 8 ++-- response-fractal-serializer.md | 8 ++-- response-fractal.md | 6 +-- response-object.md | 8 ++-- response-with.md | 10 ++--- set-total-records.md | 8 ++-- skip-paging.md | 8 ++-- smart-search.md | 8 ++-- upgrade.md | 70 +++++++++++++++++----------------- whitelist.md | 6 +-- with-trashed.md | 8 ++-- xss.md | 12 +++--- 58 files changed, 301 insertions(+), 301 deletions(-) diff --git a/add-column.md b/add-column.md index 5188d0a..b5f278d 100644 --- a/add-column.md +++ b/add-column.md @@ -6,12 +6,12 @@ You can add a custom column on your response by using `addColumn` api. ## Add Column with Blade Syntax ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Add Column with Closure ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,18 +40,18 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `addColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) - ->addColumn('intro', 'users.datatables.intro') + return DataTables::eloquent($model) + ->addColumn('intro', 'users.DataTables.intro') ->make(true); }); ``` -Then create your view on `resources/views/users/datatables/intro.blade.php`. +Then create your view on `resources/views/users/DataTables/intro.blade.php`. ```php Hi {{ $name }}! ``` @@ -62,12 +62,12 @@ Hi {{ $name }}! > {tip} Just pass the column order as the third argument of `addColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!', 2) ->make(true); }); diff --git a/blacklist.md b/blacklist.md index 2600340..df25725 100644 --- a/blacklist.md +++ b/blacklist.md @@ -3,13 +3,13 @@ Sorting and searching will not work on columns explicitly defined as blacklisted. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->blacklist(['password', 'name']) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/buttons-config.md b/buttons-config.md index 9887c42..f74dfe7 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -2,7 +2,7 @@ ## Artisan Console Configurations -Namespace configuration is used by the datatables command generator. +Namespace configuration is used by the DataTables command generator. ```php 'namespace' => [ @@ -16,7 +16,7 @@ This is the base namespace/directory to be created when a new DataTable was call This directory is appended on default Laravel namespace. **Usage:** -```php artisan datatables:make User``` +```php artisan DataTables:make User``` **Output:** ```App\DataTables\UserDataTable``` @@ -26,7 +26,7 @@ This directory is appended on default Laravel namespace. ### 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``` +**Usage:** ```php artisan DataTables:make Post --model``` **Output:** ```App\DataTables\PostDataTable``` **With Model:** ```App\Post`` **Export filename:** ```posts_(timestamp)``` diff --git a/buttons-console.md b/buttons-console.md index 702d9a2..0d21c47 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -15,7 +15,7 @@ php artisan list In this example, we will create a DataTable service class. ``` -php artisan datatables:make Posts +php artisan DataTables:make Posts ``` This will create an `PostsDataTable` class on `app\DataTables` directory. @@ -24,24 +24,24 @@ This will create an `PostsDataTable` class on `app\DataTables` directory. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\Datatables\Engines\BaseEngine + * @return \Yajra\DataTables\Engines\BaseEngine */ public function dataTable() { - return $this->datatables + return $this->DataTables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } /** - * Get the query object to be processed by dataTables. + * Get the query object to be processed by DataTables. * * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection */ @@ -55,7 +55,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\Datatables\Html\Builder + * @return \Yajra\DataTables\Html\Builder */ public function html() { @@ -98,7 +98,7 @@ class PostsDataTable extends DataTable In this example, we will pass a `--model` option to set the model to be used by our DataTable. ``` -php artisan datatables:make Posts --model +php artisan DataTables:make Posts --model ``` This will generate a `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. @@ -110,24 +110,24 @@ The exported filename will also be set to `posts_(timestamp)`. namespace App\DataTables; use App\Post; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\Datatables\Engines\BaseEngine + * @return \Yajra\DataTables\Engines\BaseEngine */ public function dataTable() { - return $this->datatables + return $this->DataTables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } /** - * Get the query object to be processed by dataTables. + * Get the query object to be processed by DataTables. * * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection */ @@ -141,7 +141,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\Datatables\Html\Builder + * @return \Yajra\DataTables\Html\Builder */ public function html() { @@ -185,9 +185,9 @@ class PostsDataTable extends DataTable In this example, we will pass a `--model-namespace` option to set the model namespace to be used by our DataTable. ``` -php artisan datatables:make Posts --model-namespace="Models\Client" +php artisan DataTables:make Posts --model-namespace="Models\Client" ``` -It will implicitly activate `--model` option and override the `model` parameter in `datatables-buttons` config file. +It will implicitly activate `--model` option and override the `model` parameter in `DataTables-buttons` config file. This will allow to use a non-standard namespace if front-end and back-end models are in separate namespace for example. @@ -197,7 +197,7 @@ This will allow to use a non-standard namespace if front-end and back-end models In this example, we will pass a `--action` option to set a custom path for the action column view. ``` -php artisan datatables:make Posts --action="client.action" +php artisan DataTables:make Posts --action="client.action" ``` If not provided, a default path will be used. It will needs to be changed thereafter. @@ -206,7 +206,7 @@ If not provided, a default path will be used. It will needs to be changed therea In this example, we will pass a `--columns` option to set the columns to be used by our DataTable. ``` -php artisan datatables:make Posts --columns="id,title,author" +php artisan DataTables:make Posts --columns="id,title,author" ``` If not provided, a default set of columns will be used. It will needs to be manually changed thereafter. @@ -217,7 +217,7 @@ If not provided, a default set of columns will be used. It will needs to be manu DataTable scope is class that we can use to limit our database search results based on the defined query scopes. ``` -php artisan datatables:scope ActiveUser +php artisan DataTables:scope ActiveUser ``` This will create an `ActiveUser` class on `app\DataTables\Scopes` directory. @@ -225,9 +225,9 @@ This will create an `ActiveUser` class on `app\DataTables\Scopes` directory. ```php namespace App\DataTables\Scopes; -use Yajra\Datatables\Contracts\DataTableScopeContract; +use Yajra\DataTables\Contracts\DataTablescopeContract; -class ActiveUser implements DataTableScopeContract +class ActiveUser implements DataTablescopeContract { /** * Apply a query scope. diff --git a/buttons-custom.md b/buttons-custom.md index 42e7905..9330875 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -11,7 +11,7 @@ request) and enabling a `myCustomAction`. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -35,4 +35,4 @@ class UsersDataTable extends DataTable } ``` -Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). +Take a look at `Yajra\DataTables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). diff --git a/buttons-export.md b/buttons-export.md index 43b1d9a..eef8400 100644 --- a/buttons-export.md +++ b/buttons-export.md @@ -10,7 +10,7 @@ Export button group includes `excel`, `csv` and `pdf` button. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -36,7 +36,7 @@ To enable exporting to excel, set `excel` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -62,7 +62,7 @@ To enable exporting to csv, set `csv` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -88,7 +88,7 @@ To enable exporting to pdf, set `pdf` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -114,7 +114,7 @@ To enable print button, set `print` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -140,7 +140,7 @@ To enable reset button, set `reset` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -166,7 +166,7 @@ To enable reload button, set `reload` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { diff --git a/buttons-extended.md b/buttons-extended.md index abd364f..1d5a6f1 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -6,14 +6,14 @@ We can now extend and reuse our DataTable class inside our controller by using ` ## Upgrading from v1.0 to v1.1 -- Upgrade to `laravel-datatables-buttons:^1.1` +- Upgrade to `laravel-DataTables-buttons:^1.1` - Rename `ajax()` method to `dataTable()` - Remove `->make(true)` from the method chain. ```php public function ajax() { - return $this->datatables + return $this->DataTables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view') ->make(true) @@ -26,7 +26,7 @@ TO ```php public function dataTable() { - return $this->datatables + return $this->DataTables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } @@ -35,7 +35,7 @@ TO ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ - return $dataTable->before(function (\Yajra\Datatables\Engines\BaseEngine $dataTable) { + return $dataTable->before(function (\Yajra\DataTables\Engines\BaseEngine $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); }) ->response(function (\Illuminate\Support\Collection $response) { @@ -43,7 +43,7 @@ Route::get('datatable', function(RolesDataTable $dataTable){ return $response; }) - ->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { + ->withHtml(function(\Yajra\DataTables\Html\Builder $builder) { $builder->columns(['id', 'name', 'etc...']); }) ->with('key', 'value') diff --git a/buttons-installation.md b/buttons-installation.md index 23d3e02..8708e48 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,20 +2,20 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^2.0` +`composer require yajra/laravel-DataTables-buttons:^2.0` Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, - Yajra\Datatables\ButtonsServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\ButtonsServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=datatables-buttons +php artisan vendor:publish --tag=DataTables-buttons ``` diff --git a/buttons-starter.md b/buttons-starter.md index 1229484..e67c05b 100644 --- a/buttons-starter.md +++ b/buttons-starter.md @@ -3,7 +3,7 @@ ## Create Users DataTable ``` -php artisan datatables:make Users +php artisan DataTables:make Users ``` ## Update UsersDataTable @@ -15,7 +15,7 @@ Update `UsersDataTable` class and set the columns and parameters needed to rende namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -68,9 +68,9 @@ Our `users.index` view located at `resources/views/users/index.blade.php`. @endsection @push('scripts') - - - + + + {!! $dataTable->scripts() !!} @endpush -``` \ No newline at end of file +``` diff --git a/contributing.md b/contributing.md index 4a8812f..ebabcae 100644 --- a/contributing.md +++ b/contributing.md @@ -2,7 +2,7 @@ Contributions are **welcome** and will be fully **credited**. -We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-datatables). +We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-DataTables). ## Pull Requests @@ -16,4 +16,4 @@ We accept contributions via Pull Requests on [Github](https://github.com/yajra/l - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. -**Happy coding**! \ No newline at end of file +**Happy coding**! diff --git a/documentation.md b/documentation.md index 5801f76..25704b3 100644 --- a/documentation.md +++ b/documentation.md @@ -8,10 +8,10 @@ - [Installation](/docs/{{package}}/{{version}}/installation) - Getting Started - [Introduction](/docs/{{package}}/{{version}}/introduction) - - [Demo Application](https://datatables.yajrabox.com/) + - [Demo Application](https://DataTables.yajrabox.com/) - Tutorials - - [Quick Starter](https://datatables.yajrabox.com/starter) - - [Service Implementation](https://datatables.yajrabox.com/service) + - [Quick Starter](https://DataTables.yajrabox.com/starter) + - [Service Implementation](https://DataTables.yajrabox.com/service) - Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) @@ -75,7 +75,7 @@ - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) - - [Github](https://github.com/yajra/laravel-datatables-html) + - [Github](https://github.com/yajra/laravel-DataTables-html) - Buttons - [Installation](/docs/{{package}}/{{version}}/buttons-installation) @@ -86,5 +86,5 @@ - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - - [Github](https://github.com/yajra/laravel-datatables-buttons) + - [Github](https://github.com/yajra/laravel-DataTables-buttons) diff --git a/edit-column.md b/edit-column.md index 86463c6..ea88f02 100644 --- a/edit-column.md +++ b/edit-column.md @@ -6,12 +6,12 @@ You can edit a column on your response by using `editColumn` api. ## Edit Column with Blade Syntax ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->editColumn('name', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Edit Column with Closure ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->editColumn('name', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,18 +40,18 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `editColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) - ->editColumn('name', 'users.datatables.into') + return DataTables::eloquent($model) + ->editColumn('name', 'users.DataTables.into') ->make(true); }); ``` -Then create your view on `resources/views/users/datatables/name.blade.php`. +Then create your view on `resources/views/users/DataTables/name.blade.php`. ```php Hi {{ $name }}! ``` diff --git a/engine-collection.md b/engine-collection.md index 9aea44b..c822568 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -1,13 +1,13 @@ # Collection Data Source -You may use Laravel's Collection as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. +You may use Laravel's Collection as data source for your DataTables. +You can look at `Yajra\DataTables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. ## Collection via Factory ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $collection = collect([ @@ -16,7 +16,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return Datatables::of($collection)->make(true); + return DataTables::of($collection)->make(true); }); ``` @@ -24,7 +24,7 @@ Route::get('user-data', function() { ## Collection via Facade ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $collection = collect([ @@ -33,7 +33,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return Datatables::queryBuilder($collection)->make(true); + return DataTables::queryBuilder($collection)->make(true); }); ``` @@ -41,16 +41,16 @@ Route::get('user-data', function() { ## Collection via Dependency Injection ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $DataTables) { $collection = collect([ ['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Jane'], ['id' => 3, 'name' => 'James'], ]); - return $datatables->queryBuilder($collection)->make(true); + return $DataTables->queryBuilder($collection)->make(true); }); ``` @@ -65,6 +65,6 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return app('datatables')->queryBuilder($collection)->make(true); + return app('DataTables')->queryBuilder($collection)->make(true); }); ``` diff --git a/engine-eloquent.md b/engine-eloquent.md index baafbc2..1b3aae3 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -1,18 +1,18 @@ # Eloquent Data Source -You may use Laravel's Eloquent Model as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. +You may use Laravel's Eloquent Model as data source for your DataTables. +You can look at `Yajra\DataTables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. ## Eloquent via Factory ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::of($model)->make(true); + return DataTables::of($model)->make(true); }); ``` @@ -20,12 +20,12 @@ Route::get('user-data', function() { ## Eloquent via Facade ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model)->make(true); + return DataTables::eloquent($model)->make(true); }); ``` @@ -33,12 +33,12 @@ Route::get('user-data', function() { ## Eloquent via Dependency Injection ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $DataTables) { $model = App\User::query(); - return $datatables->eloquent($model)->make(true); + return $DataTables->eloquent($model)->make(true); }); ``` @@ -48,6 +48,6 @@ Route::get('user-data', function(Datatables $datatables) { Route::get('user-data', function() { $model = App\User::query(); - return app('datatables')->eloquent($model)->make(true); + return app('DataTables')->eloquent($model)->make(true); }); ``` diff --git a/engine-query.md b/engine-query.md index e013a70..da2b2d9 100644 --- a/engine-query.md +++ b/engine-query.md @@ -1,19 +1,19 @@ # Query Builder Data Source -You may use Laravel's Query Builder as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. +You may use Laravel's Query Builder as data source for your DataTables. +You can look at `Yajra\DataTables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. ## Query Builder via Factory ```php use DB; -use Datatables; +use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return Datatables::of($query)->make(true); + return DataTables::of($query)->make(true); }); ``` @@ -22,12 +22,12 @@ Route::get('user-data', function() { ```php use DB; -use Datatables; +use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return Datatables::queryBuilder($query)->make(true); + return DataTables::queryBuilder($query)->make(true); }); ``` @@ -36,12 +36,12 @@ Route::get('user-data', function() { ```php use DB; -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $DataTables) { $query = DB::table('users'); - return $datatables->queryBuilder($query)->make(true); + return $DataTables->queryBuilder($query)->make(true); }); ``` @@ -53,6 +53,6 @@ use DB; Route::get('user-data', function() { $query = DB::table('users'); - return app('datatables')->queryBuilder($query)->make(true); + return app('DataTables')->queryBuilder($query)->make(true); }); ``` diff --git a/error-handler.md b/error-handler.md index 4d812de..cf0f07f 100644 --- a/error-handler.md +++ b/error-handler.md @@ -4,10 +4,10 @@ Laravel DataTables allows you to configure how you want to handle server-side er Below are the options available for error handling. ## ERROR CONFIGURATIONS -Configuration is located at `config/datatables.php` under `error` key. -You can also configure via env by setting `DATATABLES_ERROR` key appropriately. +Configuration is located at `config/DataTables.php` under `error` key. +You can also configure via env by setting `DataTables_ERROR` key appropriately. -The default configuration is `env('DATATABLES_ERROR', null)`. +The default configuration is `env('DataTables_ERROR', null)`. - [NULL](#null-error) : `'error' => null` @@ -31,12 +31,12 @@ If set to `null`, the actual exception message will be used on error response. ## THROW Error -If set to `'throw'`, the package will throw a `\Yajra\Datatables\Exception`. +If set to `'throw'`, the package will throw a `\Yajra\DataTables\Exception`. You can then use your custom error handler if needed. **Example Error Handler** -Update `app\Exceptions\Handler.php` and register dataTables error exception handler. +Update `app\Exceptions\Handler.php` and register DataTables error exception handler. ```php /** @@ -48,7 +48,7 @@ Update `app\Exceptions\Handler.php` and register dataTables error exception hand */ public function render($request, Exception $exception) { - if ($exception instanceof \Yajra\Datatables\Exception) { + if ($exception instanceof \Yajra\DataTables\Exception) { return response([ 'draw' => 0, 'recordsTotal' => 0, diff --git a/filter-column.md b/filter-column.md index eb1c2a7..1ddb296 100644 --- a/filter-column.md +++ b/filter-column.md @@ -4,7 +4,7 @@ In some cases, we need to implement a custom search for a specific column. To achieve this, you can use `filterColumn` api. ```php -use Datatables; +use DataTables; use DB; Route::get('user-data', function() { @@ -16,7 +16,7 @@ Route::get('user-data', function() { 'updated_at', ]); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filterColumn('fullname', function($query, $keyword) { $sql = "CONCAT(users.first_name,'-',users.last_name) like ?"; $query->whereRaw($sql, ["%{$keyword}%"]); diff --git a/general-settings.md b/general-settings.md index f1cac2f..1c105a0 100644 --- a/general-settings.md +++ b/general-settings.md @@ -3,7 +3,7 @@ ## Introduction You can change the package behavior by updating the configuration file. -The configuration file can be found at `config/datatables.php`. +The configuration file can be found at `config/DataTables.php`. ## Smart Search @@ -43,20 +43,20 @@ DataTables internal index id response column name. ## Engines A list of available engines. -This is where you can register your custom datatables engine. +This is where you can register your custom DataTables engine. ```php 'engines' => [ - 'eloquent' => Yajra\Datatables\Engines\EloquentEngine::class, - 'query' => Yajra\Datatables\Engines\QueryBuilderEngine::class, - 'collection' => Yajra\Datatables\Engines\CollectionEngine::class, + 'eloquent' => Yajra\DataTables\Engines\EloquentEngine::class, + 'query' => Yajra\DataTables\Engines\QueryBuilderEngine::class, + 'collection' => Yajra\DataTables\Engines\CollectionEngine::class, // add your custom engine ], ``` ## Builders -A list of accepted data source / builders of datatables with their corresponding engine handler. +A list of accepted data source / builders of DataTables with their corresponding engine handler. ```php 'builders' => [ @@ -86,10 +86,10 @@ Default fractal serializer to be used when serializing the response. ## Script Template DataTables html builder script blade template. -If published, the file will installed on `resources/views/vendor/datatables/script.blade.php`. +If published, the file will installed on `resources/views/vendor/DataTables/script.blade.php`. ```php -'script_template' => 'datatables::script', +'script_template' => 'DataTables::script', ``` diff --git a/html-builder-ajax.md b/html-builder-ajax.md index 3954330..9f22146 100644 --- a/html-builder-ajax.md +++ b/html-builder-ajax.md @@ -2,7 +2,7 @@ Ajax is an option that you set to tell `dataTable` where to fetch it's data. -See [datatables.net](https://datatables.net/) official documentation for [`ajax option`](https://datatables.net/reference/option/ajax) for details. +See [DataTables.net](https://DataTables.net/) official documentation for [`ajax option`](https://DataTables.net/reference/option/ajax) for details. **Syntax** ```php @@ -20,7 +20,7 @@ When the attribute passed is a `string`. The builder will treat this as the `URL $builder->ajax(route('users.data')); ``` -> {tip} Setting ajax to `null` or `empty string` will use the current url where Datatables was used. +> {tip} Setting ajax to `null` or `empty string` will use the current url where DataTables was used. **Array Attributes** @@ -35,7 +35,7 @@ $builder->ajax([ ``` ### URL Option -URL option represents the `url` where dataTables will fetch it's json data. +URL option represents the `url` where DataTables will fetch it's json data. ### Type Option Type option represents the type of request (`GET/POST`) that we will use when sending a request to the server. diff --git a/html-builder-callbacks.md b/html-builder-callbacks.md index b48b3fc..83f3e3c 100644 --- a/html-builder-callbacks.md +++ b/html-builder-callbacks.md @@ -1,6 +1,6 @@ # Html Builder Event Callbacks -You can use a `js` string for each valid callback as documented on [`datatables.net`](https://datatables.net/reference/option/) callback options list. +You can use a `js` string for each valid callback as documented on [`DataTables.net`](https://DataTables.net/reference/option/) callback options list. ## DataTables - Callbacks | Callback | Description | @@ -27,4 +27,4 @@ In this example, we will hook on the the `drawCallback` of dataTable. $builder->parameters([ 'drawCallback' => 'function() { alert("Table Draw Callback") }', ]); -``` \ No newline at end of file +``` diff --git a/html-builder-checkbox.md b/html-builder-checkbox.md index 0fe6b20..46bdd82 100644 --- a/html-builder-checkbox.md +++ b/html-builder-checkbox.md @@ -7,7 +7,7 @@ The default attributes of checkbox column are: ```php [ 'defaultContent' => 'html->attributes($attributes) . '/>', - 'title' => $this->form->checkbox('', '', false, ['id' => 'dataTablesCheckbox']), + 'title' => $this->form->checkbox('', '', false, ['id' => 'DataTablesCheckbox']), 'data' => 'checkbox', 'name' => 'checkbox', 'orderable' => false, @@ -16,4 +16,4 @@ The default attributes of checkbox column are: 'printable' => true, 'width' => '10px', ]; -``` \ No newline at end of file +``` diff --git a/html-builder-column.md b/html-builder-column.md index 7dd9748..b8e7fe7 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -1,6 +1,6 @@ # Html Builder Column -Builder Column represents the column to be rendered by your dataTables. +Builder Column represents the column to be rendered by your DataTables. You can use `addColumn` api to add a single column and `columns` api to add multiple columns. @@ -22,11 +22,11 @@ $column = [ ]; ``` -You also need to look at [`datatables.net`](https://datatables.net/reference/option/columns) official columns documentation for further reference. +You also need to look at [`DataTables.net`](https://DataTables.net/reference/option/columns) official columns documentation for further reference. ### Name (Optional) Name attribute represents the `column` name from your data source. -Datatables will use this attribute when performing search and ordering functions. +DataTables will use this attribute when performing search and ordering functions. > {tip} If not set, `name` attribute will automatically be set to same value as `data` attribute. diff --git a/html-builder-config.md b/html-builder-config.md index b851797..1e2a583 100644 --- a/html-builder-config.md +++ b/html-builder-config.md @@ -1,9 +1,9 @@ # Html Builder Config Default table attributes are now configurable. -To begin, you need to publish the config by running `php artisan vendor:publish --tag=datatables-html` +To begin, you need to publish the config by running `php artisan vendor:publish --tag=DataTables-html` -Published config is located at `config/datatables-html.php`. +Published config is located at `config/DataTables-html.php`. You can then update the default table attributes that you prefer for every table rendered using the builder class. ```php @@ -13,4 +13,4 @@ return [ 'id' => 'dataTableId' ] ]; -``` \ No newline at end of file +``` diff --git a/html-builder-index.md b/html-builder-index.md index 8cf4690..9179154 100644 --- a/html-builder-index.md +++ b/html-builder-index.md @@ -19,4 +19,4 @@ The default attributes of index column are: ]; ``` -The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `Datatables`. \ No newline at end of file +The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `DataTables`. diff --git a/html-builder-macro.md b/html-builder-macro.md index 52fcb5a..e7f4ce4 100644 --- a/html-builder-macro.md +++ b/html-builder-macro.md @@ -4,8 +4,8 @@ You can extend DataTables HTML Builder using `macro`. ## Example macro: ```php -use Yajra\Datatables\Html\Builder; -use Yajra\Datatables\Html\Column; +use Yajra\DataTables\Html\Builder; +use Yajra\DataTables\Html\Column; Builder::macro('addEditColumn', function () { $attributes = [ @@ -28,4 +28,4 @@ Builder::macro('addEditColumn', function () { $builder = new Builder; $builder->addEditColumn()->ajax()->parameters([]); -``` \ No newline at end of file +``` diff --git a/html-builder-minified-ajax.md b/html-builder-minified-ajax.md index 20a529e..fce59c3 100644 --- a/html-builder-minified-ajax.md +++ b/html-builder-minified-ajax.md @@ -1,7 +1,7 @@ # Html Builder Minified Ajax Ajax is an option that you set to tell `dataTable` where to fetch it's data. -But unlike the regular ajax method, `minifiedAjax` minifies the url generated by dataTables by removing any unnecessary query parameters thus shortening the url +But unlike the regular ajax method, `minifiedAjax` minifies the url generated by DataTables by removing any unnecessary query parameters thus shortening the url from approx 1500 url length down to 500. Shortening the URL will help us prevent any browser and development issues concerning the URL length exceeding the max allowed value. diff --git a/html-builder-parameters.md b/html-builder-parameters.md index cd60c84..f4f0463 100644 --- a/html-builder-parameters.md +++ b/html-builder-parameters.md @@ -2,7 +2,7 @@ Parameters are basically the options you pass when declaring your `DataTable` js script. -See the [`datatables.net`](https://datatables.net) official documentation for the list of all possible [`options`](https://datatables.net/reference/option/). +See the [`DataTables.net`](https://DataTables.net) official documentation for the list of all possible [`options`](https://DataTables.net/reference/option/). ## Example @@ -13,7 +13,7 @@ $builder->parameters([ 'info' => false, 'searchDelay' => 350, 'language' => [ - 'url' => url('js/dataTables/language.json') + 'url' => url('js/DataTables/language.json') ], ]); -``` \ No newline at end of file +``` diff --git a/html-builder-table.md b/html-builder-table.md index d57a894..25289b9 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -8,12 +8,12 @@ Table api accepts two parameters: `$builder->table(array $attributes, $footer = ## Table Example with Footer ```php -use Datatables; -use Yajra\Datatables\Html\Builder; +use DataTables; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return Datatables::of(User::query())->make(true); + return DataTables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-builder.md b/html-builder.md index 3b663c2..3a4156e 100644 --- a/html-builder.md +++ b/html-builder.md @@ -1,6 +1,6 @@ # Html Builder -Datatables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. +DataTables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. ## Html Builder via Dependency Injection @@ -8,7 +8,7 @@ Datatables has a built-in html builder that you can use to automatically generat You can use the `Builder` class by using Dependency Injection. ```php -use Yajra\Datatables\Html\Builder; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { }); @@ -19,17 +19,17 @@ Route::get('users', function(Builder $builder) { ```php Route::get('users', function() { - $builder = app('datatables.html'); + $builder = app('DataTables.html'); }); ``` - -## Html Builder from Datatables instance + +## Html Builder from DataTables instance ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('users', function(Datatables $dataTable) { +Route::get('users', function(DataTables $dataTable) { $builder = $dataTable->getHtmlBuilder(); }); ``` @@ -38,12 +38,12 @@ Route::get('users', function(Datatables $dataTable) { ## Html Builder Example ```php -use Datatables; -use Yajra\Datatables\Html\Builder; +use DataTables; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return Datatables::of(User::query())->make(true); + return DataTables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-installation.md b/html-installation.md index d8061b1..e0e14c4 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,20 +4,20 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^2.0` +`composer require yajra/laravel-DataTables-html:^2.0` Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, - Yajra\Datatables\HtmlServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\HtmlServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=datatables-html +php artisan vendor:publish --tag=DataTables-html ``` diff --git a/index-column.md b/index-column.md index 396b499..09a84e4 100644 --- a/index-column.md +++ b/index-column.md @@ -4,16 +4,16 @@ In some cases, you need to track the index of the records on your response. To achieve this, you can add an index column on your response by using `addIndexColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addIndexColumn() ->make(true); }); ``` Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. -The default index column name is `DT_Row_Index` \ No newline at end of file +The default index column name is `DT_Row_Index` diff --git a/installation.md b/installation.md index f704375..bdb6710 100644 --- a/installation.md +++ b/installation.md @@ -2,7 +2,7 @@ - [Installation](#installation) - [Requirements](#requirements) - - [Installing Laravel-Datatables](#installing-laravel-datatables-oracle) + - [Installing Laravel-DataTables](#installing-laravel-DataTables-oracle) - [Configuration](#configuration) @@ -12,17 +12,17 @@ ### Requirements - [Laravel 5.4](https://github.com/laravel/framework) -- [jQuery DataTables v1.10.x](http://datatables.net/) +- [jQuery DataTables v1.10.x](http://DataTables.net/) - -### Installing Laravel Datatables + +### Installing Laravel DataTables -Laravel Datatables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-datatables-oracle). +Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-DataTables-oracle). Run the following command in your project to get the latest version of the package: ``` -composer require yajra/laravel-datatables-oracle:^7.0 +composer require yajra/laravel-DataTables-oracle:^7.0 ``` @@ -33,13 +33,13 @@ Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=datatables +php artisan vendor:publish --tag=DataTables ``` diff --git a/introduction.md b/introduction.md index fc30ba1..1b0b3a5 100644 --- a/introduction.md +++ b/introduction.md @@ -10,25 +10,25 @@ Laravel attempts to take the pain out of development by easing common tasks used Official documentation of Laravel is available at [laravel.com](https://laravel.com/) - + ## DataTables DataTables is a plug-in for the [jQuery](https://jquery.com/) Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table. -Official documentation of DataTables is available at [datatables.net](https://datatables.net) +Official documentation of DataTables is available at [DataTables.net](https://DataTables.net) - + ## Laravel DataTables -[![Join the chat at https://gitter.im/yajra/laravel-datatables](https://badges.gitter.im/yajra/laravel-datatables.svg)](https://gitter.im/yajra/laravel-datatables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![License](https://poser.pugx.org/yajra/laravel-datatables-oracle/license)](https://packagist.org/packages/yajra/laravel-datatables-oracle) +[![Join the chat at https://gitter.im/yajra/laravel-DataTables](https://badges.gitter.im/yajra/laravel-DataTables.svg)](https://gitter.im/yajra/laravel-DataTables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![License](https://poser.pugx.org/yajra/laravel-DataTables-oracle/license)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) [![Laravel 4.2|5.x](https://img.shields.io/badge/Laravel-4.2|5.x-orange.svg)](http://laravel.com) -[![Latest Stable Version](https://poser.pugx.org/yajra/laravel-datatables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-datatables-oracle) -[![Build Status](https://travis-ci.org/yajra/laravel-datatables.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables) +[![Latest Stable Version](https://poser.pugx.org/yajra/laravel-DataTables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) +[![Build Status](https://travis-ci.org/yajra/laravel-DataTables.svg?branch=master)](https://travis-ci.org/yajra/laravel-DataTables) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/{{package}}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/{{package}}/?branch=master) -[![Total Downloads](https://poser.pugx.org/yajra/laravel-datatables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-datatables-oracle) +[![Total Downloads](https://poser.pugx.org/yajra/laravel-DataTables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) -Laravel DataTables is a package that handles the [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) using [Laravel](http://laravel.com). +Laravel DataTables is a package that handles the [server-side](https://www.DataTables.net/manual/server-side) works of [DataTables](http://DataTables.net) using [Laravel](http://laravel.com). diff --git a/manual-order.md b/manual-order.md index c64b98d..b752682 100644 --- a/manual-order.md +++ b/manual-order.md @@ -1,15 +1,15 @@ # Manual Order -You may optionally disable the default ordering function of Datatables and write you own using `order` api. +You may optionally disable the default ordering function of DataTables and write you own using `order` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->order(function ($query) { if (request()->has('name')) { $query->orderBy('name', 'asc'); @@ -21,4 +21,4 @@ Route::get('user-data', function() { }) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/manual-search.md b/manual-search.md index 167c7d6..8a5e3a2 100644 --- a/manual-search.md +++ b/manual-search.md @@ -7,12 +7,12 @@ To achieve this, you can use the `filter` api. ## Manual Searching without Global Search ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); @@ -32,12 +32,12 @@ Route::get('user-data', function() { > {tip} To enable global search with filter api, just set the 2nd argument to `true`. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); diff --git a/only-trashed.md b/only-trashed.md index fbbed15..ea836b7 100644 --- a/only-trashed.md +++ b/only-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Only Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include only trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include only trashed records in the results. To achieve this, we can use `onlyTrashed` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::onlyTrashed()->query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->onlyTrashed() ->make(true); }); -``` \ No newline at end of file +``` diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index d2fc0ef..ada5986 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -1,14 +1,14 @@ # Order by NULLS LAST -This api will set Datatables to perform ordering with `NULLS LAST` option. +This api will set DataTables to perform ordering with `NULLS LAST` option. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderByNullsLast() ->make(true); }); diff --git a/order-column.md b/order-column.md index 5d19648..1f41f9c 100644 --- a/order-column.md +++ b/order-column.md @@ -7,13 +7,13 @@ In some cases, you may want to use a custom order sql for a specific column. To In this example, we will order the column name with nulls as last result. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderColumn('name', '-name $1') ->make(true); }); -``` \ No newline at end of file +``` diff --git a/order-columns.md b/order-columns.md index 3fef0f1..45075bb 100644 --- a/order-columns.md +++ b/order-columns.md @@ -11,13 +11,13 @@ In some cases, you may want to use a custom order sql for a set of columns. To a In this example, we will order the column name with nulls as last result. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderColumns(['name', 'email'], '-:column $1') ->make(true); }); -``` \ No newline at end of file +``` diff --git a/query-builder.md b/query-builder.md index daa9c52..69ac5d6 100644 --- a/query-builder.md +++ b/query-builder.md @@ -1,16 +1,16 @@ # Query Builder Extension -Datatables instance allows you to proxy a database query call. +DataTables instance allows you to proxy a database query call. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - $dataTable = Datatables::eloquent($model); + $dataTable = DataTables::eloquent($model); $dataTable->where('company_id', 2); return $dataTable->make(true); }); -``` \ No newline at end of file +``` diff --git a/raw-columns.md b/raw-columns.md index e612e3f..aa09353 100644 --- a/raw-columns.md +++ b/raw-columns.md @@ -5,12 +5,12 @@ In cases where you want to render an html content, please use `rawColumns` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('link', 'Html Column') ->addColumn('action', 'path.to.view') ->rawColumns(['link', 'action']) diff --git a/readme.md b/readme.md index 084b4be..b2985c7 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ -# Laravel Datatables Documentation +# Laravel DataTables Documentation ## Contribution Guidelines If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. -For example, documentation for Laravel Datatables 6.0 would be submitted to the `6.0` branch. -Documentation intended for the next release of Laravel Datatables should be submitted to the `master` branch. \ No newline at end of file +For example, documentation for Laravel DataTables 6.0 would be submitted to the `6.0` branch. +Documentation intended for the next release of Laravel DataTables should be submitted to the `master` branch. diff --git a/regex.md b/regex.md index 9c5774e..02b1000 100644 --- a/regex.md +++ b/regex.md @@ -1,6 +1,6 @@ # Regex Searching -Datatables has the ability to perform search using regular expressions. +DataTables has the ability to perform search using regular expressions. > Regex search only works and tested on the following Laravel DB drivers: MySQL, SQLite and Oracle. @@ -22,4 +22,4 @@ $('#example').dataTable({ "regex": true } }); -``` \ No newline at end of file +``` diff --git a/relationships.md b/relationships.md index 91f1b29..d6442a4 100644 --- a/relationships.md +++ b/relationships.md @@ -1,17 +1,17 @@ # Eager Loading Relationships -`Datatables` support searching and sorting of eager loaded relationships when using `Eloquent`. +`DataTables` support searching and sorting of eager loaded relationships when using `Eloquent`. In this example, I will show you how to setup a eager loading search using `EloquentEngine`. To enable search, we need to eager load the relationship we intend to use using Laravel's `User::with('posts')` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::with('posts'); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('posts', function (User $user) { return $user->posts->map(function($post) { return str_limit($post->title, 30, '...'); diff --git a/releases.md b/releases.md index 6659c2f..f12c3a7 100644 --- a/releases.md +++ b/releases.md @@ -1,25 +1,25 @@ # Release Notes -- [Laravel Datatables 7.0](#7.0) +- [Laravel DataTables 7.0](#7.0) -## Laravel Datatables 7.0 +## Laravel DataTables 7.0 -Laravel Datatables 7.0 splits Laravel Datatables 6.x into a main package and plugins packages for more flexibile and pluggable design. +Laravel DataTables 7.0 splits Laravel DataTables 6.x into a main package and plugins packages for more flexibile and pluggable design. ### Buttons Plugin -On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. +On Laravel DataTables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues/832) which actually makes sense since not all users are using the export functionality. ### DomPDF -`DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. +`DomPDF` dependency is now optional on Laravel DataTables 7.0 and was transferred to Buttons plugin. And the `Buttons` plugin will now give you a choice to install it or not. This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. ### Other Changes #### Request property -`Datatables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. +`DataTables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. ```php $dataTable = Datatable::of(User::query()); diff --git a/remove-column.md b/remove-column.md index a5a8751..71fbec7 100644 --- a/remove-column.md +++ b/remove-column.md @@ -3,12 +3,12 @@ You can remove a column on your response by using `removeColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->removeColumn('password') ->make(true); }); diff --git a/response-array.md b/response-array.md index f462000..59270ee 100644 --- a/response-array.md +++ b/response-array.md @@ -1,14 +1,14 @@ # Array Response -Array response is the default response of Datatables. +Array response is the default response of DataTables. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(); }); @@ -28,4 +28,4 @@ Route::get('user-data', function() { [120, "Adeline Mayert-name", "rice.elian@abshire.com", "2016-07-31 23:25:50", "2016-07-31 23:25:50"] ] } -``` \ No newline at end of file +``` diff --git a/response-fractal-serializer.md b/response-fractal-serializer.md index ac4ddc5..229e0da 100644 --- a/response-fractal-serializer.md +++ b/response-fractal-serializer.md @@ -1,16 +1,16 @@ # Fractal Transformer Serializer -You can set the serializer to be used by Datatables using `setSerializer` api. Serializer should be used with `setTransformer` api. +You can set the serializer to be used by DataTables using `setSerializer` api. Serializer should be used with `setTransformer` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTransformer(new App\Transformers\UserTransformer) ->setSerializer(new App\Serializers\CustomSerializer) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/response-fractal.md b/response-fractal.md index 6b015e3..5d15ead 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -4,13 +4,13 @@ When using tranformer, all response manipulations must be done via transformer. Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, etc... should be avoided when using fractal. ```php -use Datatables; +use DataTables; use App\Transformers\UserTransformer; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTransformer(new UserTransformer) ->make(true); }); @@ -54,4 +54,4 @@ class UserTransformer extends TransformerAbstract return $this->collection($posts, new PostTransformer); } } -``` \ No newline at end of file +``` diff --git a/response-object.md b/response-object.md index aa6d340..4e8e966 100644 --- a/response-object.md +++ b/response-object.md @@ -1,14 +1,14 @@ # Object Response -To convert the response of Datatables to an object, just pass `true` on `make` api. +To convert the response of DataTables to an object, just pass `true` on `make` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -40,4 +40,4 @@ Route::get('user-data', function() { "superior_id": 1 }] } -``` \ No newline at end of file +``` diff --git a/response-with.md b/response-with.md index db1967d..4fdad8c 100644 --- a/response-with.md +++ b/response-with.md @@ -6,12 +6,12 @@ You can add additional server data on your response by using `with` api. ## Adding response using key and value ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->with('posts', 100) ->with('comments', 20) ->make(true); @@ -22,12 +22,12 @@ Route::get('user-data', function() { ## Adding response using array ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->with([ 'posts' => 100, 'comments' => 20, @@ -64,4 +64,4 @@ Route::get('user-data', function() { "posts": 100, "comments": 20 } -``` \ No newline at end of file +``` diff --git a/set-total-records.md b/set-total-records.md index 4d907c1..3c59d39 100644 --- a/set-total-records.md +++ b/set-total-records.md @@ -1,16 +1,16 @@ # Set Total Records -In some cases, we need to manually set the total records of our `Datatables` and skip its internal counting functionality. +In some cases, we need to manually set the total records of our `DataTables` and skip its internal counting functionality. To achieve this, we can use `setTotalRecords($count)` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTotalRecords(100) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/skip-paging.md b/skip-paging.md index f3fdb48..c76c1ad 100644 --- a/skip-paging.md +++ b/skip-paging.md @@ -1,15 +1,15 @@ # Skip Paging -To skip paging of `Datatables`, we can use `skipPaging` api or just set `paging: false` on our javascript. +To skip paging of `DataTables`, we can use `skipPaging` api or just set `paging: false` on our javascript. ## Using PHP ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::withTrashed()->query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->skipPaging() ->make(true); }); @@ -27,4 +27,4 @@ $(document).ready(function() { }); }); -``` \ No newline at end of file +``` diff --git a/smart-search.md b/smart-search.md index df3ab5a..170918f 100644 --- a/smart-search.md +++ b/smart-search.md @@ -1,16 +1,16 @@ # Runtime Smart Search -You can optionally enable/disable Datatables smart search feature by using `smart` api by passing `true` or `false` as the argument. +You can optionally enable/disable DataTables smart search feature by using `smart` api by passing `true` or `false` as the argument. Default argument value is `true`. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->smart(false) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/upgrade.md b/upgrade.md index 2fbea02..2b8f2d1 100644 --- a/upgrade.md +++ b/upgrade.md @@ -6,31 +6,31 @@ To upgrade Laravel DataTables from version 7.x to version 8.x: ```bash -composer require yajra/laravel-datatables-oracle:8.* -php artisan vendor:publish --tag=datatables --force +composer require yajra/laravel-DataTables-oracle:8.* +php artisan vendor:publish --tag=DataTables --force ``` If you are using service approach / buttons plugin: ```bash -composer require yajra/laravel-datatables-buttons:3.* -php artisan vendor:publish --tag=datatables-buttons --force +composer require yajra/laravel-DataTables-buttons:3.* +php artisan vendor:publish --tag=DataTables-buttons --force ``` If you are using html plugin: ```bash -composer require yajra/laravel-datatables-html:3.* -php artisan vendor:publish --tag=datatables-html --force +composer require yajra/laravel-DataTables-html:3.* +php artisan vendor:publish --tag=DataTables-html --force ``` If you are using fractal: ```bash -composer require yajra/laravel-datatables-fractal:1.* -php artisan vendor:publish --tag=datatables-fractal --force +composer require yajra/laravel-DataTables-fractal:1.* +php artisan vendor:publish --tag=DataTables-fractal --force ``` ## [v8] Namespace -The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. @@ -38,20 +38,20 @@ The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. DataTables Facade was renamed to `Yajra\DataTables\Facades\DataTables`. If you want to continue using your old facade, just register the alias on your `config/app.php` file. ```php -'Datatables' => Yajra\DataTables\Facades\DataTables::class +'DataTables' => Yajra\DataTables\Facades\DataTables::class ``` ## [v8] DataTables Factory class -DataTables factory class is now renamed to `DataTables` from `Datatables`. If you are injecting `Yajra\Datatables\Datatables` on your code, you must update it to `Yajra\DataTables\DataTables`. +DataTables factory class is now renamed to `DataTables` from `DataTables`. If you are injecting `Yajra\DataTables\DataTables` on your code, you must update it to `Yajra\DataTables\DataTables`. `DataTables::of()` method is now an alias of new `DataTables::make()` method to match Laravel's factory api structure. ## [v8] DataTables Buttons Changes -> See https://github.com/yajra/laravel-datatables-buttons/blob/master/CHANGELOG.md for full changelog. +> See https://github.com/yajra/laravel-DataTables-buttons/blob/master/CHANGELOG.md for full changelog. -- The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +- The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. - Constructor dependencies were removed. - You need to instanstiate the DataTable class within the `dataTable()` method: @@ -59,7 +59,7 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo ```php // FROM public function dataTable() { - return $this->datatables->eloquent($this->query()); + return $this->DataTables->eloquent($this->query()); } ``` ```php @@ -73,15 +73,15 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo Or inject the factory using method injection. Note that you need to inject your classes first before the query results. ```php use Yajra\DataTables\DataTables; - public function dataTable(DataTables $dataTables, $query) { - return $dataTables->eloquent($query); + public function dataTable(DataTables $DataTables, $query) { + return $DataTables->eloquent($query); } ``` - Query method results are automatically injected on `dataTable($query)` api. ```php use Yajra\DataTables\DataTables; - public function dataTable($query, DataTables $dataTables) { - return $dataTables->eloquent($query); + public function dataTable($query, DataTables $DataTables) { + return $DataTables->eloquent($query); } public function query() { @@ -95,13 +95,13 @@ DataTables factory class is now renamed to `DataTables` from `Datatables`. If yo Builder Methods: `ajax(), dataTable(), query()` - `DataTableContract` contract removed. -- `DataTableScopeContract` contract renamed to `DataTableScope`. +- `DataTablescopeContract` contract renamed to `DataTablescope`. - `DataTableButtonsContract` contract renamed to `DataTableButtons`. ## [v8] DataTables Html Changes -The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. +The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. @@ -119,35 +119,35 @@ DataTables now supports `SoftDeletes` hence, there is no need to use `withTrashe ## Upgrading from v6.x to v7.x -To upgrade Laravel Datatables from version 6.x to version 7.x: +To upgrade Laravel DataTables from version 6.x to version 7.x: ```sh -composer require yajra/laravel-datatables-oracle:^7.0 -php artisan vendor:publish --tag=datatables --force +composer require yajra/laravel-DataTables-oracle:^7.0 +php artisan vendor:publish --tag=DataTables --force ``` ### Service Approach Service class is now extracted to own plugin, `Buttons Plugin`. If you are using the service approach, you need to perform the following: ```sh -composer require yajra/laravel-datatables-buttons:^1.0 +composer require yajra/laravel-DataTables-buttons:^1.0 ``` -Register `Yajra\Datatables\ButtonsServiceProvider::class` on `config/app.php` and publish config. +Register `Yajra\DataTables\ButtonsServiceProvider::class` on `config/app.php` and publish config. ```php -php artisan vendor:publish --tag=datatables-buttons --force +php artisan vendor:publish --tag=DataTables-buttons --force ``` ### Html Builder -HTML builder is now extracted to own plugin, If you are using Datatables html builder, you need to perform the following: +HTML builder is now extracted to own plugin, If you are using DataTables html builder, you need to perform the following: > HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. ```sh -composer require yajra/laravel-datatables-html:^1.0 -php artisan vendor:publish --tag=datatables-html --force +composer require yajra/laravel-DataTables-html:^1.0 +php artisan vendor:publish --tag=DataTables-html --force ``` @@ -155,7 +155,7 @@ php artisan vendor:publish --tag=datatables-html --force All columns are now escaped by default to protect us from XSS attack. To allow columns to have an html content, use `rawColumns` api. ```php -Datatables::of(User::query()) +DataTables::of(User::query()) ->addColumn('href', 'Html Content') ->rawColumns(['href']) ->make(true); @@ -164,8 +164,8 @@ Datatables::of(User::query()) ## Upgrading from v5.x to v6.x -- Change all occurrences of `yajra\Datatables` to `Yajra\Datatables`. (Use Sublime's find and replace all for faster update). -- Remove `Datatables` facade registration. -- Temporarily comment out `Yajra\Datatables\DatatablesServiceProvider`. -- Update package version on your composer.json and use `yajra/laravel-datatables-oracle: ~6.0` -- Uncomment the provider `Yajra\Datatables\DatatablesServiceProvider`. +- Change all occurrences of `yajra\DataTables` to `Yajra\DataTables`. (Use Sublime's find and replace all for faster update). +- Remove `DataTables` facade registration. +- Temporarily comment out `Yajra\DataTables\DataTablesServiceProvider`. +- Update package version on your composer.json and use `yajra/laravel-DataTables-oracle: ~6.0` +- Uncomment the provider `Yajra\DataTables\DataTablesServiceProvider`. diff --git a/whitelist.md b/whitelist.md index 39578df..bfffd12 100644 --- a/whitelist.md +++ b/whitelist.md @@ -3,13 +3,13 @@ Sorting and searching will only work on columns explicitly defined as whitelist. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->whitelist(['name', 'email']) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/with-trashed.md b/with-trashed.md index 64c1aee..44f8407 100644 --- a/with-trashed.md +++ b/with-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include trashed records in the results. To achieve this, we can use `withTrashed` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query()->withTrashed(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->withTrashed() ->make(true); }); -``` \ No newline at end of file +``` diff --git a/xss.md b/xss.md index 56792a5..ca0d35c 100644 --- a/xss.md +++ b/xss.md @@ -8,7 +8,7 @@ Since v7.0, all dataTable response are encoded to prevent XSS attack. In case yo ## Raw Columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->rawColumns(['name', 'action']) ->make(true); ``` @@ -19,7 +19,7 @@ return Datatables::eloquent(Role::select()) ## Escape selected fields ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns(['name']) ->make(true); ``` @@ -27,7 +27,7 @@ return Datatables::eloquent(Role::select()) ## Escape all columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns() ->make(true); ``` @@ -36,7 +36,7 @@ return Datatables::eloquent(Role::select()) ## Remove escaping of all columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns([]) ->make(true); ``` @@ -45,7 +45,7 @@ return Datatables::eloquent(Role::select()) ## Escape by output index ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns([0]) ->make(); - ``` \ No newline at end of file + ``` From 4ec15a4838f1b04c63e64130eef49cd36c8bf2af Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:35:43 +0800 Subject: [PATCH 067/264] Revert "Rename Datatables to DataTables." This reverts commit 46d912e0a333461523929151b42ad16eab08cf36. --- add-column.md | 20 +++++----- blacklist.md | 6 +-- buttons-config.md | 6 +-- buttons-console.md | 38 +++++++++--------- buttons-custom.md | 4 +- buttons-export.md | 14 +++---- buttons-extended.md | 10 ++--- buttons-installation.md | 8 ++-- buttons-starter.md | 12 +++--- contributing.md | 4 +- documentation.md | 10 ++--- edit-column.md | 16 ++++---- engine-collection.md | 20 +++++----- engine-eloquent.md | 20 +++++----- engine-query.md | 20 +++++----- error-handler.md | 12 +++--- filter-column.md | 4 +- general-settings.md | 16 ++++---- html-builder-ajax.md | 6 +-- html-builder-callbacks.md | 4 +- html-builder-checkbox.md | 4 +- html-builder-column.md | 6 +-- html-builder-config.md | 6 +-- html-builder-index.md | 2 +- html-builder-macro.md | 6 +-- html-builder-minified-ajax.md | 2 +- html-builder-parameters.md | 6 +-- html-builder-table.md | 6 +-- html-builder.md | 20 +++++----- html-installation.md | 8 ++-- index-column.md | 6 +-- installation.md | 16 ++++---- introduction.md | 18 ++++----- manual-order.md | 8 ++-- manual-search.md | 8 ++-- only-trashed.md | 8 ++-- order-by-nulls-last.md | 6 +-- order-column.md | 6 +-- order-columns.md | 6 +-- query-builder.md | 8 ++-- raw-columns.md | 4 +- readme.md | 6 +-- regex.md | 4 +- relationships.md | 6 +-- releases.md | 12 +++--- remove-column.md | 4 +- response-array.md | 8 ++-- response-fractal-serializer.md | 8 ++-- response-fractal.md | 6 +-- response-object.md | 8 ++-- response-with.md | 10 ++--- set-total-records.md | 8 ++-- skip-paging.md | 8 ++-- smart-search.md | 8 ++-- upgrade.md | 70 +++++++++++++++++----------------- whitelist.md | 6 +-- with-trashed.md | 8 ++-- xss.md | 12 +++--- 58 files changed, 301 insertions(+), 301 deletions(-) diff --git a/add-column.md b/add-column.md index b5f278d..5188d0a 100644 --- a/add-column.md +++ b/add-column.md @@ -6,12 +6,12 @@ You can add a custom column on your response by using `addColumn` api. ## Add Column with Blade Syntax ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Add Column with Closure ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('intro', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,18 +40,18 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `addColumn` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) - ->addColumn('intro', 'users.DataTables.intro') + return Datatables::eloquent($model) + ->addColumn('intro', 'users.datatables.intro') ->make(true); }); ``` -Then create your view on `resources/views/users/DataTables/intro.blade.php`. +Then create your view on `resources/views/users/datatables/intro.blade.php`. ```php Hi {{ $name }}! ``` @@ -62,12 +62,12 @@ Hi {{ $name }}! > {tip} Just pass the column order as the third argument of `addColumn` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!', 2) ->make(true); }); diff --git a/blacklist.md b/blacklist.md index df25725..2600340 100644 --- a/blacklist.md +++ b/blacklist.md @@ -3,13 +3,13 @@ Sorting and searching will not work on columns explicitly defined as blacklisted. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->blacklist(['password', 'name']) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/buttons-config.md b/buttons-config.md index f74dfe7..9887c42 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -2,7 +2,7 @@ ## Artisan Console Configurations -Namespace configuration is used by the DataTables command generator. +Namespace configuration is used by the datatables command generator. ```php 'namespace' => [ @@ -16,7 +16,7 @@ This is the base namespace/directory to be created when a new DataTable was call This directory is appended on default Laravel namespace. **Usage:** -```php artisan DataTables:make User``` +```php artisan datatables:make User``` **Output:** ```App\DataTables\UserDataTable``` @@ -26,7 +26,7 @@ This directory is appended on default Laravel namespace. ### 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``` +**Usage:** ```php artisan datatables:make Post --model``` **Output:** ```App\DataTables\PostDataTable``` **With Model:** ```App\Post`` **Export filename:** ```posts_(timestamp)``` diff --git a/buttons-console.md b/buttons-console.md index 0d21c47..702d9a2 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -15,7 +15,7 @@ php artisan list In this example, we will create a DataTable service class. ``` -php artisan DataTables:make Posts +php artisan datatables:make Posts ``` This will create an `PostsDataTable` class on `app\DataTables` directory. @@ -24,24 +24,24 @@ This will create an `PostsDataTable` class on `app\DataTables` directory. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\DataTables\Engines\BaseEngine + * @return \Yajra\Datatables\Engines\BaseEngine */ public function dataTable() { - return $this->DataTables + return $this->datatables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } /** - * Get the query object to be processed by DataTables. + * Get the query object to be processed by dataTables. * * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection */ @@ -55,7 +55,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\DataTables\Html\Builder + * @return \Yajra\Datatables\Html\Builder */ public function html() { @@ -98,7 +98,7 @@ class PostsDataTable extends DataTable In this example, we will pass a `--model` option to set the model to be used by our DataTable. ``` -php artisan DataTables:make Posts --model +php artisan datatables:make Posts --model ``` This will generate a `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. @@ -110,24 +110,24 @@ The exported filename will also be set to `posts_(timestamp)`. namespace App\DataTables; use App\Post; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\DataTables\Engines\BaseEngine + * @return \Yajra\Datatables\Engines\BaseEngine */ public function dataTable() { - return $this->DataTables + return $this->datatables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } /** - * Get the query object to be processed by DataTables. + * Get the query object to be processed by dataTables. * * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection */ @@ -141,7 +141,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\DataTables\Html\Builder + * @return \Yajra\Datatables\Html\Builder */ public function html() { @@ -185,9 +185,9 @@ class PostsDataTable extends DataTable In this example, we will pass a `--model-namespace` option to set the model namespace to be used by our DataTable. ``` -php artisan DataTables:make Posts --model-namespace="Models\Client" +php artisan datatables:make Posts --model-namespace="Models\Client" ``` -It will implicitly activate `--model` option and override the `model` parameter in `DataTables-buttons` config file. +It will implicitly activate `--model` option and override the `model` parameter in `datatables-buttons` config file. This will allow to use a non-standard namespace if front-end and back-end models are in separate namespace for example. @@ -197,7 +197,7 @@ This will allow to use a non-standard namespace if front-end and back-end models In this example, we will pass a `--action` option to set a custom path for the action column view. ``` -php artisan DataTables:make Posts --action="client.action" +php artisan datatables:make Posts --action="client.action" ``` If not provided, a default path will be used. It will needs to be changed thereafter. @@ -206,7 +206,7 @@ If not provided, a default path will be used. It will needs to be changed therea In this example, we will pass a `--columns` option to set the columns to be used by our DataTable. ``` -php artisan DataTables:make Posts --columns="id,title,author" +php artisan datatables:make Posts --columns="id,title,author" ``` If not provided, a default set of columns will be used. It will needs to be manually changed thereafter. @@ -217,7 +217,7 @@ If not provided, a default set of columns will be used. It will needs to be manu DataTable scope is class that we can use to limit our database search results based on the defined query scopes. ``` -php artisan DataTables:scope ActiveUser +php artisan datatables:scope ActiveUser ``` This will create an `ActiveUser` class on `app\DataTables\Scopes` directory. @@ -225,9 +225,9 @@ This will create an `ActiveUser` class on `app\DataTables\Scopes` directory. ```php namespace App\DataTables\Scopes; -use Yajra\DataTables\Contracts\DataTablescopeContract; +use Yajra\Datatables\Contracts\DataTableScopeContract; -class ActiveUser implements DataTablescopeContract +class ActiveUser implements DataTableScopeContract { /** * Apply a query scope. diff --git a/buttons-custom.md b/buttons-custom.md index 9330875..42e7905 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -11,7 +11,7 @@ request) and enabling a `myCustomAction`. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -35,4 +35,4 @@ class UsersDataTable extends DataTable } ``` -Take a look at `Yajra\DataTables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). +Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). diff --git a/buttons-export.md b/buttons-export.md index eef8400..43b1d9a 100644 --- a/buttons-export.md +++ b/buttons-export.md @@ -10,7 +10,7 @@ Export button group includes `excel`, `csv` and `pdf` button. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -36,7 +36,7 @@ To enable exporting to excel, set `excel` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -62,7 +62,7 @@ To enable exporting to csv, set `csv` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -88,7 +88,7 @@ To enable exporting to pdf, set `pdf` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -114,7 +114,7 @@ To enable print button, set `print` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -140,7 +140,7 @@ To enable reset button, set `reset` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -166,7 +166,7 @@ To enable reload button, set `reload` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { diff --git a/buttons-extended.md b/buttons-extended.md index 1d5a6f1..abd364f 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -6,14 +6,14 @@ We can now extend and reuse our DataTable class inside our controller by using ` ## Upgrading from v1.0 to v1.1 -- Upgrade to `laravel-DataTables-buttons:^1.1` +- Upgrade to `laravel-datatables-buttons:^1.1` - Rename `ajax()` method to `dataTable()` - Remove `->make(true)` from the method chain. ```php public function ajax() { - return $this->DataTables + return $this->datatables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view') ->make(true) @@ -26,7 +26,7 @@ TO ```php public function dataTable() { - return $this->DataTables + return $this->datatables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view'); } @@ -35,7 +35,7 @@ TO ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ - return $dataTable->before(function (\Yajra\DataTables\Engines\BaseEngine $dataTable) { + return $dataTable->before(function (\Yajra\Datatables\Engines\BaseEngine $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); }) ->response(function (\Illuminate\Support\Collection $response) { @@ -43,7 +43,7 @@ Route::get('datatable', function(RolesDataTable $dataTable){ return $response; }) - ->withHtml(function(\Yajra\DataTables\Html\Builder $builder) { + ->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { $builder->columns(['id', 'name', 'etc...']); }) ->with('key', 'value') diff --git a/buttons-installation.md b/buttons-installation.md index 8708e48..23d3e02 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,20 +2,20 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-DataTables-buttons:^2.0` +`composer require yajra/laravel-datatables-buttons:^2.0` Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\DataTables\DataTablesServiceProvider::class, - Yajra\DataTables\ButtonsServiceProvider::class, + Yajra\Datatables\DatatablesServiceProvider::class, + Yajra\Datatables\ButtonsServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=DataTables-buttons +php artisan vendor:publish --tag=datatables-buttons ``` diff --git a/buttons-starter.md b/buttons-starter.md index e67c05b..1229484 100644 --- a/buttons-starter.md +++ b/buttons-starter.md @@ -3,7 +3,7 @@ ## Create Users DataTable ``` -php artisan DataTables:make Users +php artisan datatables:make Users ``` ## Update UsersDataTable @@ -15,7 +15,7 @@ Update `UsersDataTable` class and set the columns and parameters needed to rende namespace App\DataTables; use App\User; -use Yajra\DataTables\Services\DataTable; +use Yajra\Datatables\Services\DataTable; class UsersDataTable extends DataTable { @@ -68,9 +68,9 @@ Our `users.index` view located at `resources/views/users/index.blade.php`. @endsection @push('scripts') - - - + + + {!! $dataTable->scripts() !!} @endpush -``` +``` \ No newline at end of file diff --git a/contributing.md b/contributing.md index ebabcae..4a8812f 100644 --- a/contributing.md +++ b/contributing.md @@ -2,7 +2,7 @@ Contributions are **welcome** and will be fully **credited**. -We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-DataTables). +We accept contributions via Pull Requests on [Github](https://github.com/yajra/laravel-datatables). ## Pull Requests @@ -16,4 +16,4 @@ We accept contributions via Pull Requests on [Github](https://github.com/yajra/l - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. -**Happy coding**! +**Happy coding**! \ No newline at end of file diff --git a/documentation.md b/documentation.md index 25704b3..5801f76 100644 --- a/documentation.md +++ b/documentation.md @@ -8,10 +8,10 @@ - [Installation](/docs/{{package}}/{{version}}/installation) - Getting Started - [Introduction](/docs/{{package}}/{{version}}/introduction) - - [Demo Application](https://DataTables.yajrabox.com/) + - [Demo Application](https://datatables.yajrabox.com/) - Tutorials - - [Quick Starter](https://DataTables.yajrabox.com/starter) - - [Service Implementation](https://DataTables.yajrabox.com/service) + - [Quick Starter](https://datatables.yajrabox.com/starter) + - [Service Implementation](https://datatables.yajrabox.com/service) - Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) @@ -75,7 +75,7 @@ - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) - - [Github](https://github.com/yajra/laravel-DataTables-html) + - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons - [Installation](/docs/{{package}}/{{version}}/buttons-installation) @@ -86,5 +86,5 @@ - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - - [Github](https://github.com/yajra/laravel-DataTables-buttons) + - [Github](https://github.com/yajra/laravel-datatables-buttons) diff --git a/edit-column.md b/edit-column.md index ea88f02..86463c6 100644 --- a/edit-column.md +++ b/edit-column.md @@ -6,12 +6,12 @@ You can edit a column on your response by using `editColumn` api. ## Edit Column with Blade Syntax ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->editColumn('name', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Edit Column with Closure ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->editColumn('name', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,18 +40,18 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `editColumn` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) - ->editColumn('name', 'users.DataTables.into') + return Datatables::eloquent($model) + ->editColumn('name', 'users.datatables.into') ->make(true); }); ``` -Then create your view on `resources/views/users/DataTables/name.blade.php`. +Then create your view on `resources/views/users/datatables/name.blade.php`. ```php Hi {{ $name }}! ``` diff --git a/engine-collection.md b/engine-collection.md index c822568..9aea44b 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -1,13 +1,13 @@ # Collection Data Source -You may use Laravel's Collection as data source for your DataTables. -You can look at `Yajra\DataTables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. +You may use Laravel's Collection as data source for your dataTables. +You can look at `Yajra\Datatables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. ## Collection via Factory ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $collection = collect([ @@ -16,7 +16,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return DataTables::of($collection)->make(true); + return Datatables::of($collection)->make(true); }); ``` @@ -24,7 +24,7 @@ Route::get('user-data', function() { ## Collection via Facade ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $collection = collect([ @@ -33,7 +33,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return DataTables::queryBuilder($collection)->make(true); + return Datatables::queryBuilder($collection)->make(true); }); ``` @@ -41,16 +41,16 @@ Route::get('user-data', function() { ## Collection via Dependency Injection ```php -use Yajra\DataTables\DataTables; +use Yajra\Datatables\Datatables; -Route::get('user-data', function(DataTables $DataTables) { +Route::get('user-data', function(Datatables $datatables) { $collection = collect([ ['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Jane'], ['id' => 3, 'name' => 'James'], ]); - return $DataTables->queryBuilder($collection)->make(true); + return $datatables->queryBuilder($collection)->make(true); }); ``` @@ -65,6 +65,6 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return app('DataTables')->queryBuilder($collection)->make(true); + return app('datatables')->queryBuilder($collection)->make(true); }); ``` diff --git a/engine-eloquent.md b/engine-eloquent.md index 1b3aae3..baafbc2 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -1,18 +1,18 @@ # Eloquent Data Source -You may use Laravel's Eloquent Model as data source for your DataTables. -You can look at `Yajra\DataTables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. +You may use Laravel's Eloquent Model as data source for your dataTables. +You can look at `Yajra\Datatables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. ## Eloquent via Factory ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::of($model)->make(true); + return Datatables::of($model)->make(true); }); ``` @@ -20,12 +20,12 @@ Route::get('user-data', function() { ## Eloquent via Facade ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model)->make(true); + return Datatables::eloquent($model)->make(true); }); ``` @@ -33,12 +33,12 @@ Route::get('user-data', function() { ## Eloquent via Dependency Injection ```php -use Yajra\DataTables\DataTables; +use Yajra\Datatables\Datatables; -Route::get('user-data', function(DataTables $DataTables) { +Route::get('user-data', function(Datatables $datatables) { $model = App\User::query(); - return $DataTables->eloquent($model)->make(true); + return $datatables->eloquent($model)->make(true); }); ``` @@ -48,6 +48,6 @@ Route::get('user-data', function(DataTables $DataTables) { Route::get('user-data', function() { $model = App\User::query(); - return app('DataTables')->eloquent($model)->make(true); + return app('datatables')->eloquent($model)->make(true); }); ``` diff --git a/engine-query.md b/engine-query.md index da2b2d9..e013a70 100644 --- a/engine-query.md +++ b/engine-query.md @@ -1,19 +1,19 @@ # Query Builder Data Source -You may use Laravel's Query Builder as data source for your DataTables. -You can look at `Yajra\DataTables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. +You may use Laravel's Query Builder as data source for your dataTables. +You can look at `Yajra\Datatables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. ## Query Builder via Factory ```php use DB; -use DataTables; +use Datatables; Route::get('user-data', function() { $query = DB::table('users'); - return DataTables::of($query)->make(true); + return Datatables::of($query)->make(true); }); ``` @@ -22,12 +22,12 @@ Route::get('user-data', function() { ```php use DB; -use DataTables; +use Datatables; Route::get('user-data', function() { $query = DB::table('users'); - return DataTables::queryBuilder($query)->make(true); + return Datatables::queryBuilder($query)->make(true); }); ``` @@ -36,12 +36,12 @@ Route::get('user-data', function() { ```php use DB; -use Yajra\DataTables\DataTables; +use Yajra\Datatables\Datatables; -Route::get('user-data', function(DataTables $DataTables) { +Route::get('user-data', function(Datatables $datatables) { $query = DB::table('users'); - return $DataTables->queryBuilder($query)->make(true); + return $datatables->queryBuilder($query)->make(true); }); ``` @@ -53,6 +53,6 @@ use DB; Route::get('user-data', function() { $query = DB::table('users'); - return app('DataTables')->queryBuilder($query)->make(true); + return app('datatables')->queryBuilder($query)->make(true); }); ``` diff --git a/error-handler.md b/error-handler.md index cf0f07f..4d812de 100644 --- a/error-handler.md +++ b/error-handler.md @@ -4,10 +4,10 @@ Laravel DataTables allows you to configure how you want to handle server-side er Below are the options available for error handling. ## ERROR CONFIGURATIONS -Configuration is located at `config/DataTables.php` under `error` key. -You can also configure via env by setting `DataTables_ERROR` key appropriately. +Configuration is located at `config/datatables.php` under `error` key. +You can also configure via env by setting `DATATABLES_ERROR` key appropriately. -The default configuration is `env('DataTables_ERROR', null)`. +The default configuration is `env('DATATABLES_ERROR', null)`. - [NULL](#null-error) : `'error' => null` @@ -31,12 +31,12 @@ If set to `null`, the actual exception message will be used on error response. ## THROW Error -If set to `'throw'`, the package will throw a `\Yajra\DataTables\Exception`. +If set to `'throw'`, the package will throw a `\Yajra\Datatables\Exception`. You can then use your custom error handler if needed. **Example Error Handler** -Update `app\Exceptions\Handler.php` and register DataTables error exception handler. +Update `app\Exceptions\Handler.php` and register dataTables error exception handler. ```php /** @@ -48,7 +48,7 @@ Update `app\Exceptions\Handler.php` and register DataTables error exception hand */ public function render($request, Exception $exception) { - if ($exception instanceof \Yajra\DataTables\Exception) { + if ($exception instanceof \Yajra\Datatables\Exception) { return response([ 'draw' => 0, 'recordsTotal' => 0, diff --git a/filter-column.md b/filter-column.md index 1ddb296..eb1c2a7 100644 --- a/filter-column.md +++ b/filter-column.md @@ -4,7 +4,7 @@ In some cases, we need to implement a custom search for a specific column. To achieve this, you can use `filterColumn` api. ```php -use DataTables; +use Datatables; use DB; Route::get('user-data', function() { @@ -16,7 +16,7 @@ Route::get('user-data', function() { 'updated_at', ]); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->filterColumn('fullname', function($query, $keyword) { $sql = "CONCAT(users.first_name,'-',users.last_name) like ?"; $query->whereRaw($sql, ["%{$keyword}%"]); diff --git a/general-settings.md b/general-settings.md index 1c105a0..f1cac2f 100644 --- a/general-settings.md +++ b/general-settings.md @@ -3,7 +3,7 @@ ## Introduction You can change the package behavior by updating the configuration file. -The configuration file can be found at `config/DataTables.php`. +The configuration file can be found at `config/datatables.php`. ## Smart Search @@ -43,20 +43,20 @@ DataTables internal index id response column name. ## Engines A list of available engines. -This is where you can register your custom DataTables engine. +This is where you can register your custom datatables engine. ```php 'engines' => [ - 'eloquent' => Yajra\DataTables\Engines\EloquentEngine::class, - 'query' => Yajra\DataTables\Engines\QueryBuilderEngine::class, - 'collection' => Yajra\DataTables\Engines\CollectionEngine::class, + 'eloquent' => Yajra\Datatables\Engines\EloquentEngine::class, + 'query' => Yajra\Datatables\Engines\QueryBuilderEngine::class, + 'collection' => Yajra\Datatables\Engines\CollectionEngine::class, // add your custom engine ], ``` ## Builders -A list of accepted data source / builders of DataTables with their corresponding engine handler. +A list of accepted data source / builders of datatables with their corresponding engine handler. ```php 'builders' => [ @@ -86,10 +86,10 @@ Default fractal serializer to be used when serializing the response. ## Script Template DataTables html builder script blade template. -If published, the file will installed on `resources/views/vendor/DataTables/script.blade.php`. +If published, the file will installed on `resources/views/vendor/datatables/script.blade.php`. ```php -'script_template' => 'DataTables::script', +'script_template' => 'datatables::script', ``` diff --git a/html-builder-ajax.md b/html-builder-ajax.md index 9f22146..3954330 100644 --- a/html-builder-ajax.md +++ b/html-builder-ajax.md @@ -2,7 +2,7 @@ Ajax is an option that you set to tell `dataTable` where to fetch it's data. -See [DataTables.net](https://DataTables.net/) official documentation for [`ajax option`](https://DataTables.net/reference/option/ajax) for details. +See [datatables.net](https://datatables.net/) official documentation for [`ajax option`](https://datatables.net/reference/option/ajax) for details. **Syntax** ```php @@ -20,7 +20,7 @@ When the attribute passed is a `string`. The builder will treat this as the `URL $builder->ajax(route('users.data')); ``` -> {tip} Setting ajax to `null` or `empty string` will use the current url where DataTables was used. +> {tip} Setting ajax to `null` or `empty string` will use the current url where Datatables was used. **Array Attributes** @@ -35,7 +35,7 @@ $builder->ajax([ ``` ### URL Option -URL option represents the `url` where DataTables will fetch it's json data. +URL option represents the `url` where dataTables will fetch it's json data. ### Type Option Type option represents the type of request (`GET/POST`) that we will use when sending a request to the server. diff --git a/html-builder-callbacks.md b/html-builder-callbacks.md index 83f3e3c..b48b3fc 100644 --- a/html-builder-callbacks.md +++ b/html-builder-callbacks.md @@ -1,6 +1,6 @@ # Html Builder Event Callbacks -You can use a `js` string for each valid callback as documented on [`DataTables.net`](https://DataTables.net/reference/option/) callback options list. +You can use a `js` string for each valid callback as documented on [`datatables.net`](https://datatables.net/reference/option/) callback options list. ## DataTables - Callbacks | Callback | Description | @@ -27,4 +27,4 @@ In this example, we will hook on the the `drawCallback` of dataTable. $builder->parameters([ 'drawCallback' => 'function() { alert("Table Draw Callback") }', ]); -``` +``` \ No newline at end of file diff --git a/html-builder-checkbox.md b/html-builder-checkbox.md index 46bdd82..0fe6b20 100644 --- a/html-builder-checkbox.md +++ b/html-builder-checkbox.md @@ -7,7 +7,7 @@ The default attributes of checkbox column are: ```php [ 'defaultContent' => 'html->attributes($attributes) . '/>', - 'title' => $this->form->checkbox('', '', false, ['id' => 'DataTablesCheckbox']), + 'title' => $this->form->checkbox('', '', false, ['id' => 'dataTablesCheckbox']), 'data' => 'checkbox', 'name' => 'checkbox', 'orderable' => false, @@ -16,4 +16,4 @@ The default attributes of checkbox column are: 'printable' => true, 'width' => '10px', ]; -``` +``` \ No newline at end of file diff --git a/html-builder-column.md b/html-builder-column.md index b8e7fe7..7dd9748 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -1,6 +1,6 @@ # Html Builder Column -Builder Column represents the column to be rendered by your DataTables. +Builder Column represents the column to be rendered by your dataTables. You can use `addColumn` api to add a single column and `columns` api to add multiple columns. @@ -22,11 +22,11 @@ $column = [ ]; ``` -You also need to look at [`DataTables.net`](https://DataTables.net/reference/option/columns) official columns documentation for further reference. +You also need to look at [`datatables.net`](https://datatables.net/reference/option/columns) official columns documentation for further reference. ### Name (Optional) Name attribute represents the `column` name from your data source. -DataTables will use this attribute when performing search and ordering functions. +Datatables will use this attribute when performing search and ordering functions. > {tip} If not set, `name` attribute will automatically be set to same value as `data` attribute. diff --git a/html-builder-config.md b/html-builder-config.md index 1e2a583..b851797 100644 --- a/html-builder-config.md +++ b/html-builder-config.md @@ -1,9 +1,9 @@ # Html Builder Config Default table attributes are now configurable. -To begin, you need to publish the config by running `php artisan vendor:publish --tag=DataTables-html` +To begin, you need to publish the config by running `php artisan vendor:publish --tag=datatables-html` -Published config is located at `config/DataTables-html.php`. +Published config is located at `config/datatables-html.php`. You can then update the default table attributes that you prefer for every table rendered using the builder class. ```php @@ -13,4 +13,4 @@ return [ 'id' => 'dataTableId' ] ]; -``` +``` \ No newline at end of file diff --git a/html-builder-index.md b/html-builder-index.md index 9179154..8cf4690 100644 --- a/html-builder-index.md +++ b/html-builder-index.md @@ -19,4 +19,4 @@ The default attributes of index column are: ]; ``` -The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `DataTables`. +The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `Datatables`. \ No newline at end of file diff --git a/html-builder-macro.md b/html-builder-macro.md index e7f4ce4..52fcb5a 100644 --- a/html-builder-macro.md +++ b/html-builder-macro.md @@ -4,8 +4,8 @@ You can extend DataTables HTML Builder using `macro`. ## Example macro: ```php -use Yajra\DataTables\Html\Builder; -use Yajra\DataTables\Html\Column; +use Yajra\Datatables\Html\Builder; +use Yajra\Datatables\Html\Column; Builder::macro('addEditColumn', function () { $attributes = [ @@ -28,4 +28,4 @@ Builder::macro('addEditColumn', function () { $builder = new Builder; $builder->addEditColumn()->ajax()->parameters([]); -``` +``` \ No newline at end of file diff --git a/html-builder-minified-ajax.md b/html-builder-minified-ajax.md index fce59c3..20a529e 100644 --- a/html-builder-minified-ajax.md +++ b/html-builder-minified-ajax.md @@ -1,7 +1,7 @@ # Html Builder Minified Ajax Ajax is an option that you set to tell `dataTable` where to fetch it's data. -But unlike the regular ajax method, `minifiedAjax` minifies the url generated by DataTables by removing any unnecessary query parameters thus shortening the url +But unlike the regular ajax method, `minifiedAjax` minifies the url generated by dataTables by removing any unnecessary query parameters thus shortening the url from approx 1500 url length down to 500. Shortening the URL will help us prevent any browser and development issues concerning the URL length exceeding the max allowed value. diff --git a/html-builder-parameters.md b/html-builder-parameters.md index f4f0463..cd60c84 100644 --- a/html-builder-parameters.md +++ b/html-builder-parameters.md @@ -2,7 +2,7 @@ Parameters are basically the options you pass when declaring your `DataTable` js script. -See the [`DataTables.net`](https://DataTables.net) official documentation for the list of all possible [`options`](https://DataTables.net/reference/option/). +See the [`datatables.net`](https://datatables.net) official documentation for the list of all possible [`options`](https://datatables.net/reference/option/). ## Example @@ -13,7 +13,7 @@ $builder->parameters([ 'info' => false, 'searchDelay' => 350, 'language' => [ - 'url' => url('js/DataTables/language.json') + 'url' => url('js/dataTables/language.json') ], ]); -``` +``` \ No newline at end of file diff --git a/html-builder-table.md b/html-builder-table.md index 25289b9..d57a894 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -8,12 +8,12 @@ Table api accepts two parameters: `$builder->table(array $attributes, $footer = ## Table Example with Footer ```php -use DataTables; -use Yajra\DataTables\Html\Builder; +use Datatables; +use Yajra\Datatables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return DataTables::of(User::query())->make(true); + return Datatables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-builder.md b/html-builder.md index 3a4156e..3b663c2 100644 --- a/html-builder.md +++ b/html-builder.md @@ -1,6 +1,6 @@ # Html Builder -DataTables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. +Datatables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. ## Html Builder via Dependency Injection @@ -8,7 +8,7 @@ DataTables has a built-in html builder that you can use to automatically generat You can use the `Builder` class by using Dependency Injection. ```php -use Yajra\DataTables\Html\Builder; +use Yajra\Datatables\Html\Builder; Route::get('users', function(Builder $builder) { }); @@ -19,17 +19,17 @@ Route::get('users', function(Builder $builder) { ```php Route::get('users', function() { - $builder = app('DataTables.html'); + $builder = app('datatables.html'); }); ``` - -## Html Builder from DataTables instance + +## Html Builder from Datatables instance ```php -use Yajra\DataTables\DataTables; +use Yajra\Datatables\Datatables; -Route::get('users', function(DataTables $dataTable) { +Route::get('users', function(Datatables $dataTable) { $builder = $dataTable->getHtmlBuilder(); }); ``` @@ -38,12 +38,12 @@ Route::get('users', function(DataTables $dataTable) { ## Html Builder Example ```php -use DataTables; -use Yajra\DataTables\Html\Builder; +use Datatables; +use Yajra\Datatables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return DataTables::of(User::query())->make(true); + return Datatables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-installation.md b/html-installation.md index e0e14c4..d8061b1 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,20 +4,20 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-DataTables-html:^2.0` +`composer require yajra/laravel-datatables-html:^2.0` Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\DataTables\DataTablesServiceProvider::class, - Yajra\DataTables\HtmlServiceProvider::class, + Yajra\Datatables\DatatablesServiceProvider::class, + Yajra\Datatables\HtmlServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=DataTables-html +php artisan vendor:publish --tag=datatables-html ``` diff --git a/index-column.md b/index-column.md index 09a84e4..396b499 100644 --- a/index-column.md +++ b/index-column.md @@ -4,16 +4,16 @@ In some cases, you need to track the index of the records on your response. To achieve this, you can add an index column on your response by using `addIndexColumn` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addIndexColumn() ->make(true); }); ``` Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. -The default index column name is `DT_Row_Index` +The default index column name is `DT_Row_Index` \ No newline at end of file diff --git a/installation.md b/installation.md index bdb6710..f704375 100644 --- a/installation.md +++ b/installation.md @@ -2,7 +2,7 @@ - [Installation](#installation) - [Requirements](#requirements) - - [Installing Laravel-DataTables](#installing-laravel-DataTables-oracle) + - [Installing Laravel-Datatables](#installing-laravel-datatables-oracle) - [Configuration](#configuration) @@ -12,17 +12,17 @@ ### Requirements - [Laravel 5.4](https://github.com/laravel/framework) -- [jQuery DataTables v1.10.x](http://DataTables.net/) +- [jQuery DataTables v1.10.x](http://datatables.net/) - -### Installing Laravel DataTables + +### Installing Laravel Datatables -Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-DataTables-oracle). +Laravel Datatables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-datatables-oracle). Run the following command in your project to get the latest version of the package: ``` -composer require yajra/laravel-DataTables-oracle:^7.0 +composer require yajra/laravel-datatables-oracle:^7.0 ``` @@ -33,13 +33,13 @@ Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\Datatables\DatatablesServiceProvider::class, ], ``` After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=DataTables +php artisan vendor:publish --tag=datatables ``` diff --git a/introduction.md b/introduction.md index 1b0b3a5..fc30ba1 100644 --- a/introduction.md +++ b/introduction.md @@ -10,25 +10,25 @@ Laravel attempts to take the pain out of development by easing common tasks used Official documentation of Laravel is available at [laravel.com](https://laravel.com/) - + ## DataTables DataTables is a plug-in for the [jQuery](https://jquery.com/) Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, and will add advanced interaction controls to any HTML table. -Official documentation of DataTables is available at [DataTables.net](https://DataTables.net) +Official documentation of DataTables is available at [datatables.net](https://datatables.net) - + ## Laravel DataTables -[![Join the chat at https://gitter.im/yajra/laravel-DataTables](https://badges.gitter.im/yajra/laravel-DataTables.svg)](https://gitter.im/yajra/laravel-DataTables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![License](https://poser.pugx.org/yajra/laravel-DataTables-oracle/license)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) +[![Join the chat at https://gitter.im/yajra/laravel-datatables](https://badges.gitter.im/yajra/laravel-datatables.svg)](https://gitter.im/yajra/laravel-datatables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![License](https://poser.pugx.org/yajra/laravel-datatables-oracle/license)](https://packagist.org/packages/yajra/laravel-datatables-oracle) [![Laravel 4.2|5.x](https://img.shields.io/badge/Laravel-4.2|5.x-orange.svg)](http://laravel.com) -[![Latest Stable Version](https://poser.pugx.org/yajra/laravel-DataTables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) -[![Build Status](https://travis-ci.org/yajra/laravel-DataTables.svg?branch=master)](https://travis-ci.org/yajra/laravel-DataTables) +[![Latest Stable Version](https://poser.pugx.org/yajra/laravel-datatables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-datatables-oracle) +[![Build Status](https://travis-ci.org/yajra/laravel-datatables.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/{{package}}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/{{package}}/?branch=master) -[![Total Downloads](https://poser.pugx.org/yajra/laravel-DataTables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-DataTables-oracle) +[![Total Downloads](https://poser.pugx.org/yajra/laravel-datatables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-datatables-oracle) -Laravel DataTables is a package that handles the [server-side](https://www.DataTables.net/manual/server-side) works of [DataTables](http://DataTables.net) using [Laravel](http://laravel.com). +Laravel DataTables is a package that handles the [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) using [Laravel](http://laravel.com). diff --git a/manual-order.md b/manual-order.md index b752682..c64b98d 100644 --- a/manual-order.md +++ b/manual-order.md @@ -1,15 +1,15 @@ # Manual Order -You may optionally disable the default ordering function of DataTables and write you own using `order` api. +You may optionally disable the default ordering function of Datatables and write you own using `order` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->order(function ($query) { if (request()->has('name')) { $query->orderBy('name', 'asc'); @@ -21,4 +21,4 @@ Route::get('user-data', function() { }) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/manual-search.md b/manual-search.md index 8a5e3a2..167c7d6 100644 --- a/manual-search.md +++ b/manual-search.md @@ -7,12 +7,12 @@ To achieve this, you can use the `filter` api. ## Manual Searching without Global Search ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); @@ -32,12 +32,12 @@ Route::get('user-data', function() { > {tip} To enable global search with filter api, just set the 2nd argument to `true`. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); diff --git a/only-trashed.md b/only-trashed.md index ea836b7..fbbed15 100644 --- a/only-trashed.md +++ b/only-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Only Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include only trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include only trashed records in the results. To achieve this, we can use `onlyTrashed` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::onlyTrashed()->query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->onlyTrashed() ->make(true); }); -``` +``` \ No newline at end of file diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index ada5986..d2fc0ef 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -1,14 +1,14 @@ # Order by NULLS LAST -This api will set DataTables to perform ordering with `NULLS LAST` option. +This api will set Datatables to perform ordering with `NULLS LAST` option. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->orderByNullsLast() ->make(true); }); diff --git a/order-column.md b/order-column.md index 1f41f9c..5d19648 100644 --- a/order-column.md +++ b/order-column.md @@ -7,13 +7,13 @@ In some cases, you may want to use a custom order sql for a specific column. To In this example, we will order the column name with nulls as last result. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->orderColumn('name', '-name $1') ->make(true); }); -``` +``` \ No newline at end of file diff --git a/order-columns.md b/order-columns.md index 45075bb..3fef0f1 100644 --- a/order-columns.md +++ b/order-columns.md @@ -11,13 +11,13 @@ In some cases, you may want to use a custom order sql for a set of columns. To a In this example, we will order the column name with nulls as last result. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->orderColumns(['name', 'email'], '-:column $1') ->make(true); }); -``` +``` \ No newline at end of file diff --git a/query-builder.md b/query-builder.md index 69ac5d6..daa9c52 100644 --- a/query-builder.md +++ b/query-builder.md @@ -1,16 +1,16 @@ # Query Builder Extension -DataTables instance allows you to proxy a database query call. +Datatables instance allows you to proxy a database query call. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - $dataTable = DataTables::eloquent($model); + $dataTable = Datatables::eloquent($model); $dataTable->where('company_id', 2); return $dataTable->make(true); }); -``` +``` \ No newline at end of file diff --git a/raw-columns.md b/raw-columns.md index aa09353..e612e3f 100644 --- a/raw-columns.md +++ b/raw-columns.md @@ -5,12 +5,12 @@ In cases where you want to render an html content, please use `rawColumns` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('link', 'Html Column') ->addColumn('action', 'path.to.view') ->rawColumns(['link', 'action']) diff --git a/readme.md b/readme.md index b2985c7..084b4be 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ -# Laravel DataTables Documentation +# Laravel Datatables Documentation ## Contribution Guidelines If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. -For example, documentation for Laravel DataTables 6.0 would be submitted to the `6.0` branch. -Documentation intended for the next release of Laravel DataTables should be submitted to the `master` branch. +For example, documentation for Laravel Datatables 6.0 would be submitted to the `6.0` branch. +Documentation intended for the next release of Laravel Datatables should be submitted to the `master` branch. \ No newline at end of file diff --git a/regex.md b/regex.md index 02b1000..9c5774e 100644 --- a/regex.md +++ b/regex.md @@ -1,6 +1,6 @@ # Regex Searching -DataTables has the ability to perform search using regular expressions. +Datatables has the ability to perform search using regular expressions. > Regex search only works and tested on the following Laravel DB drivers: MySQL, SQLite and Oracle. @@ -22,4 +22,4 @@ $('#example').dataTable({ "regex": true } }); -``` +``` \ No newline at end of file diff --git a/relationships.md b/relationships.md index d6442a4..91f1b29 100644 --- a/relationships.md +++ b/relationships.md @@ -1,17 +1,17 @@ # Eager Loading Relationships -`DataTables` support searching and sorting of eager loaded relationships when using `Eloquent`. +`Datatables` support searching and sorting of eager loaded relationships when using `Eloquent`. In this example, I will show you how to setup a eager loading search using `EloquentEngine`. To enable search, we need to eager load the relationship we intend to use using Laravel's `User::with('posts')` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::with('posts'); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('posts', function (User $user) { return $user->posts->map(function($post) { return str_limit($post->title, 30, '...'); diff --git a/releases.md b/releases.md index f12c3a7..6659c2f 100644 --- a/releases.md +++ b/releases.md @@ -1,25 +1,25 @@ # Release Notes -- [Laravel DataTables 7.0](#7.0) +- [Laravel Datatables 7.0](#7.0) -## Laravel DataTables 7.0 +## Laravel Datatables 7.0 -Laravel DataTables 7.0 splits Laravel DataTables 6.x into a main package and plugins packages for more flexibile and pluggable design. +Laravel Datatables 7.0 splits Laravel Datatables 6.x into a main package and plugins packages for more flexibile and pluggable design. ### Buttons Plugin -On Laravel DataTables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. +On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues/832) which actually makes sense since not all users are using the export functionality. ### DomPDF -`DomPDF` dependency is now optional on Laravel DataTables 7.0 and was transferred to Buttons plugin. +`DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. And the `Buttons` plugin will now give you a choice to install it or not. This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. ### Other Changes #### Request property -`DataTables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. +`Datatables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. ```php $dataTable = Datatable::of(User::query()); diff --git a/remove-column.md b/remove-column.md index 71fbec7..a5a8751 100644 --- a/remove-column.md +++ b/remove-column.md @@ -3,12 +3,12 @@ You can remove a column on your response by using `removeColumn` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->removeColumn('password') ->make(true); }); diff --git a/response-array.md b/response-array.md index 59270ee..f462000 100644 --- a/response-array.md +++ b/response-array.md @@ -1,14 +1,14 @@ # Array Response -Array response is the default response of DataTables. +Array response is the default response of Datatables. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(); }); @@ -28,4 +28,4 @@ Route::get('user-data', function() { [120, "Adeline Mayert-name", "rice.elian@abshire.com", "2016-07-31 23:25:50", "2016-07-31 23:25:50"] ] } -``` +``` \ No newline at end of file diff --git a/response-fractal-serializer.md b/response-fractal-serializer.md index 229e0da..ac4ddc5 100644 --- a/response-fractal-serializer.md +++ b/response-fractal-serializer.md @@ -1,16 +1,16 @@ # Fractal Transformer Serializer -You can set the serializer to be used by DataTables using `setSerializer` api. Serializer should be used with `setTransformer` api. +You can set the serializer to be used by Datatables using `setSerializer` api. Serializer should be used with `setTransformer` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->setTransformer(new App\Transformers\UserTransformer) ->setSerializer(new App\Serializers\CustomSerializer) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/response-fractal.md b/response-fractal.md index 5d15ead..6b015e3 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -4,13 +4,13 @@ When using tranformer, all response manipulations must be done via transformer. Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, etc... should be avoided when using fractal. ```php -use DataTables; +use Datatables; use App\Transformers\UserTransformer; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->setTransformer(new UserTransformer) ->make(true); }); @@ -54,4 +54,4 @@ class UserTransformer extends TransformerAbstract return $this->collection($posts, new PostTransformer); } } -``` +``` \ No newline at end of file diff --git a/response-object.md b/response-object.md index 4e8e966..aa6d340 100644 --- a/response-object.md +++ b/response-object.md @@ -1,14 +1,14 @@ # Object Response -To convert the response of DataTables to an object, just pass `true` on `make` api. +To convert the response of Datatables to an object, just pass `true` on `make` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -40,4 +40,4 @@ Route::get('user-data', function() { "superior_id": 1 }] } -``` +``` \ No newline at end of file diff --git a/response-with.md b/response-with.md index 4fdad8c..db1967d 100644 --- a/response-with.md +++ b/response-with.md @@ -6,12 +6,12 @@ You can add additional server data on your response by using `with` api. ## Adding response using key and value ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->with('posts', 100) ->with('comments', 20) ->make(true); @@ -22,12 +22,12 @@ Route::get('user-data', function() { ## Adding response using array ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->with([ 'posts' => 100, 'comments' => 20, @@ -64,4 +64,4 @@ Route::get('user-data', function() { "posts": 100, "comments": 20 } -``` +``` \ No newline at end of file diff --git a/set-total-records.md b/set-total-records.md index 3c59d39..4d907c1 100644 --- a/set-total-records.md +++ b/set-total-records.md @@ -1,16 +1,16 @@ # Set Total Records -In some cases, we need to manually set the total records of our `DataTables` and skip its internal counting functionality. +In some cases, we need to manually set the total records of our `Datatables` and skip its internal counting functionality. To achieve this, we can use `setTotalRecords($count)` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->setTotalRecords(100) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/skip-paging.md b/skip-paging.md index c76c1ad..f3fdb48 100644 --- a/skip-paging.md +++ b/skip-paging.md @@ -1,15 +1,15 @@ # Skip Paging -To skip paging of `DataTables`, we can use `skipPaging` api or just set `paging: false` on our javascript. +To skip paging of `Datatables`, we can use `skipPaging` api or just set `paging: false` on our javascript. ## Using PHP ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::withTrashed()->query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->skipPaging() ->make(true); }); @@ -27,4 +27,4 @@ $(document).ready(function() { }); }); -``` +``` \ No newline at end of file diff --git a/smart-search.md b/smart-search.md index 170918f..df3ab5a 100644 --- a/smart-search.md +++ b/smart-search.md @@ -1,16 +1,16 @@ # Runtime Smart Search -You can optionally enable/disable DataTables smart search feature by using `smart` api by passing `true` or `false` as the argument. +You can optionally enable/disable Datatables smart search feature by using `smart` api by passing `true` or `false` as the argument. Default argument value is `true`. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->smart(false) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/upgrade.md b/upgrade.md index 2b8f2d1..2fbea02 100644 --- a/upgrade.md +++ b/upgrade.md @@ -6,31 +6,31 @@ To upgrade Laravel DataTables from version 7.x to version 8.x: ```bash -composer require yajra/laravel-DataTables-oracle:8.* -php artisan vendor:publish --tag=DataTables --force +composer require yajra/laravel-datatables-oracle:8.* +php artisan vendor:publish --tag=datatables --force ``` If you are using service approach / buttons plugin: ```bash -composer require yajra/laravel-DataTables-buttons:3.* -php artisan vendor:publish --tag=DataTables-buttons --force +composer require yajra/laravel-datatables-buttons:3.* +php artisan vendor:publish --tag=datatables-buttons --force ``` If you are using html plugin: ```bash -composer require yajra/laravel-DataTables-html:3.* -php artisan vendor:publish --tag=DataTables-html --force +composer require yajra/laravel-datatables-html:3.* +php artisan vendor:publish --tag=datatables-html --force ``` If you are using fractal: ```bash -composer require yajra/laravel-DataTables-fractal:1.* -php artisan vendor:publish --tag=DataTables-fractal --force +composer require yajra/laravel-datatables-fractal:1.* +php artisan vendor:publish --tag=datatables-fractal --force ``` ## [v8] Namespace -The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. +The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. @@ -38,20 +38,20 @@ The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. DataTables Facade was renamed to `Yajra\DataTables\Facades\DataTables`. If you want to continue using your old facade, just register the alias on your `config/app.php` file. ```php -'DataTables' => Yajra\DataTables\Facades\DataTables::class +'Datatables' => Yajra\DataTables\Facades\DataTables::class ``` ## [v8] DataTables Factory class -DataTables factory class is now renamed to `DataTables` from `DataTables`. If you are injecting `Yajra\DataTables\DataTables` on your code, you must update it to `Yajra\DataTables\DataTables`. +DataTables factory class is now renamed to `DataTables` from `Datatables`. If you are injecting `Yajra\Datatables\Datatables` on your code, you must update it to `Yajra\DataTables\DataTables`. `DataTables::of()` method is now an alias of new `DataTables::make()` method to match Laravel's factory api structure. ## [v8] DataTables Buttons Changes -> See https://github.com/yajra/laravel-DataTables-buttons/blob/master/CHANGELOG.md for full changelog. +> See https://github.com/yajra/laravel-datatables-buttons/blob/master/CHANGELOG.md for full changelog. -- The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. +- The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. - Constructor dependencies were removed. - You need to instanstiate the DataTable class within the `dataTable()` method: @@ -59,7 +59,7 @@ DataTables factory class is now renamed to `DataTables` from `DataTables`. If yo ```php // FROM public function dataTable() { - return $this->DataTables->eloquent($this->query()); + return $this->datatables->eloquent($this->query()); } ``` ```php @@ -73,15 +73,15 @@ DataTables factory class is now renamed to `DataTables` from `DataTables`. If yo Or inject the factory using method injection. Note that you need to inject your classes first before the query results. ```php use Yajra\DataTables\DataTables; - public function dataTable(DataTables $DataTables, $query) { - return $DataTables->eloquent($query); + public function dataTable(DataTables $dataTables, $query) { + return $dataTables->eloquent($query); } ``` - Query method results are automatically injected on `dataTable($query)` api. ```php use Yajra\DataTables\DataTables; - public function dataTable($query, DataTables $DataTables) { - return $DataTables->eloquent($query); + public function dataTable($query, DataTables $dataTables) { + return $dataTables->eloquent($query); } public function query() { @@ -95,13 +95,13 @@ DataTables factory class is now renamed to `DataTables` from `DataTables`. If yo Builder Methods: `ajax(), dataTable(), query()` - `DataTableContract` contract removed. -- `DataTablescopeContract` contract renamed to `DataTablescope`. +- `DataTableScopeContract` contract renamed to `DataTableScope`. - `DataTableButtonsContract` contract renamed to `DataTableButtons`. ## [v8] DataTables Html Changes -The package namespace was updated from `Yajra\DataTables` to `Yajra\DataTables`. +The package namespace was updated from `Yajra\Datatables` to `Yajra\DataTables`. > Use sublime's find and replace all feature to update all affected files. @@ -119,35 +119,35 @@ DataTables now supports `SoftDeletes` hence, there is no need to use `withTrashe ## Upgrading from v6.x to v7.x -To upgrade Laravel DataTables from version 6.x to version 7.x: +To upgrade Laravel Datatables from version 6.x to version 7.x: ```sh -composer require yajra/laravel-DataTables-oracle:^7.0 -php artisan vendor:publish --tag=DataTables --force +composer require yajra/laravel-datatables-oracle:^7.0 +php artisan vendor:publish --tag=datatables --force ``` ### Service Approach Service class is now extracted to own plugin, `Buttons Plugin`. If you are using the service approach, you need to perform the following: ```sh -composer require yajra/laravel-DataTables-buttons:^1.0 +composer require yajra/laravel-datatables-buttons:^1.0 ``` -Register `Yajra\DataTables\ButtonsServiceProvider::class` on `config/app.php` and publish config. +Register `Yajra\Datatables\ButtonsServiceProvider::class` on `config/app.php` and publish config. ```php -php artisan vendor:publish --tag=DataTables-buttons --force +php artisan vendor:publish --tag=datatables-buttons --force ``` ### Html Builder -HTML builder is now extracted to own plugin, If you are using DataTables html builder, you need to perform the following: +HTML builder is now extracted to own plugin, If you are using Datatables html builder, you need to perform the following: > HTML Builder plugin is a prerequisite of Buttons plugin. You can optionally skip this part if already installed the Buttons plugin. ```sh -composer require yajra/laravel-DataTables-html:^1.0 -php artisan vendor:publish --tag=DataTables-html --force +composer require yajra/laravel-datatables-html:^1.0 +php artisan vendor:publish --tag=datatables-html --force ``` @@ -155,7 +155,7 @@ php artisan vendor:publish --tag=DataTables-html --force All columns are now escaped by default to protect us from XSS attack. To allow columns to have an html content, use `rawColumns` api. ```php -DataTables::of(User::query()) +Datatables::of(User::query()) ->addColumn('href', 'Html Content') ->rawColumns(['href']) ->make(true); @@ -164,8 +164,8 @@ DataTables::of(User::query()) ## Upgrading from v5.x to v6.x -- Change all occurrences of `yajra\DataTables` to `Yajra\DataTables`. (Use Sublime's find and replace all for faster update). -- Remove `DataTables` facade registration. -- Temporarily comment out `Yajra\DataTables\DataTablesServiceProvider`. -- Update package version on your composer.json and use `yajra/laravel-DataTables-oracle: ~6.0` -- Uncomment the provider `Yajra\DataTables\DataTablesServiceProvider`. +- Change all occurrences of `yajra\Datatables` to `Yajra\Datatables`. (Use Sublime's find and replace all for faster update). +- Remove `Datatables` facade registration. +- Temporarily comment out `Yajra\Datatables\DatatablesServiceProvider`. +- Update package version on your composer.json and use `yajra/laravel-datatables-oracle: ~6.0` +- Uncomment the provider `Yajra\Datatables\DatatablesServiceProvider`. diff --git a/whitelist.md b/whitelist.md index bfffd12..39578df 100644 --- a/whitelist.md +++ b/whitelist.md @@ -3,13 +3,13 @@ Sorting and searching will only work on columns explicitly defined as whitelist. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->whitelist(['name', 'email']) ->make(true); }); -``` +``` \ No newline at end of file diff --git a/with-trashed.md b/with-trashed.md index 44f8407..64c1aee 100644 --- a/with-trashed.md +++ b/with-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include trashed records in the results. To achieve this, we can use `withTrashed` api. ```php -use DataTables; +use Datatables; Route::get('user-data', function() { $model = App\User::query()->withTrashed(); - return DataTables::eloquent($model) + return Datatables::eloquent($model) ->withTrashed() ->make(true); }); -``` +``` \ No newline at end of file diff --git a/xss.md b/xss.md index ca0d35c..56792a5 100644 --- a/xss.md +++ b/xss.md @@ -8,7 +8,7 @@ Since v7.0, all dataTable response are encoded to prevent XSS attack. In case yo ## Raw Columns ```php -return DataTables::eloquent(Role::select()) +return Datatables::eloquent(Role::select()) ->rawColumns(['name', 'action']) ->make(true); ``` @@ -19,7 +19,7 @@ return DataTables::eloquent(Role::select()) ## Escape selected fields ```php -return DataTables::eloquent(Role::select()) +return Datatables::eloquent(Role::select()) ->escapeColumns(['name']) ->make(true); ``` @@ -27,7 +27,7 @@ return DataTables::eloquent(Role::select()) ## Escape all columns ```php -return DataTables::eloquent(Role::select()) +return Datatables::eloquent(Role::select()) ->escapeColumns() ->make(true); ``` @@ -36,7 +36,7 @@ return DataTables::eloquent(Role::select()) ## Remove escaping of all columns ```php -return DataTables::eloquent(Role::select()) +return Datatables::eloquent(Role::select()) ->escapeColumns([]) ->make(true); ``` @@ -45,7 +45,7 @@ return DataTables::eloquent(Role::select()) ## Escape by output index ```php -return DataTables::eloquent(Role::select()) +return Datatables::eloquent(Role::select()) ->escapeColumns([0]) ->make(); - ``` + ``` \ No newline at end of file From 71ad1885ebe0909a5d0d4523572093125774f210 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:36:27 +0800 Subject: [PATCH 068/264] Rename Datatables to DataTables. --- add-column.md | 16 ++++++++-------- blacklist.md | 6 +++--- buttons-console.md | 14 +++++++------- buttons-custom.md | 4 ++-- buttons-export.md | 14 +++++++------- buttons-extended.md | 4 ++-- buttons-installation.md | 4 ++-- buttons-starter.md | 4 ++-- edit-column.md | 12 ++++++------ engine-collection.md | 14 +++++++------- engine-eloquent.md | 14 +++++++------- engine-query.md | 14 +++++++------- error-handler.md | 4 ++-- filter-column.md | 4 ++-- general-settings.md | 6 +++--- html-builder-ajax.md | 2 +- html-builder-column.md | 2 +- html-builder-index.md | 2 +- html-builder-macro.md | 6 +++--- html-builder-table.md | 6 +++--- html-builder.md | 16 ++++++++-------- html-installation.md | 4 ++-- index-column.md | 6 +++--- installation.md | 8 ++++---- manual-order.md | 8 ++++---- manual-search.md | 8 ++++---- only-trashed.md | 8 ++++---- order-by-nulls-last.md | 6 +++--- order-column.md | 6 +++--- order-columns.md | 6 +++--- query-builder.md | 8 ++++---- raw-columns.md | 4 ++-- readme.md | 6 +++--- regex.md | 4 ++-- relationships.md | 6 +++--- releases.md | 12 ++++++------ remove-column.md | 4 ++-- response-array.md | 8 ++++---- response-fractal-serializer.md | 8 ++++---- response-fractal.md | 6 +++--- response-object.md | 8 ++++---- response-with.md | 10 +++++----- set-total-records.md | 8 ++++---- skip-paging.md | 8 ++++---- smart-search.md | 8 ++++---- whitelist.md | 6 +++--- with-trashed.md | 8 ++++---- xss.md | 12 ++++++------ 48 files changed, 181 insertions(+), 181 deletions(-) diff --git a/add-column.md b/add-column.md index 5188d0a..e9cfb26 100644 --- a/add-column.md +++ b/add-column.md @@ -6,12 +6,12 @@ You can add a custom column on your response by using `addColumn` api. ## Add Column with Blade Syntax ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Add Column with Closure ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,12 +40,12 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `addColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'users.datatables.intro') ->make(true); }); @@ -62,12 +62,12 @@ Hi {{ $name }}! > {tip} Just pass the column order as the third argument of `addColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!', 2) ->make(true); }); diff --git a/blacklist.md b/blacklist.md index 2600340..df25725 100644 --- a/blacklist.md +++ b/blacklist.md @@ -3,13 +3,13 @@ Sorting and searching will not work on columns explicitly defined as blacklisted. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->blacklist(['password', 'name']) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/buttons-console.md b/buttons-console.md index 702d9a2..f13880b 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -24,14 +24,14 @@ This will create an `PostsDataTable` class on `app\DataTables` directory. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\Datatables\Engines\BaseEngine + * @return \Yajra\DataTables\Engines\BaseEngine */ public function dataTable() { @@ -55,7 +55,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\Datatables\Html\Builder + * @return \Yajra\DataTables\Html\Builder */ public function html() { @@ -110,14 +110,14 @@ The exported filename will also be set to `posts_(timestamp)`. namespace App\DataTables; use App\Post; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class PostsDataTable extends DataTable { /** * Build DataTable class. * - * @return \Yajra\Datatables\Engines\BaseEngine + * @return \Yajra\DataTables\Engines\BaseEngine */ public function dataTable() { @@ -141,7 +141,7 @@ class PostsDataTable extends DataTable /** * Optional method if you want to use html builder. * - * @return \Yajra\Datatables\Html\Builder + * @return \Yajra\DataTables\Html\Builder */ public function html() { @@ -225,7 +225,7 @@ This will create an `ActiveUser` class on `app\DataTables\Scopes` directory. ```php namespace App\DataTables\Scopes; -use Yajra\Datatables\Contracts\DataTableScopeContract; +use Yajra\DataTables\Contracts\DataTableScopeContract; class ActiveUser implements DataTableScopeContract { diff --git a/buttons-custom.md b/buttons-custom.md index 42e7905..9330875 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -11,7 +11,7 @@ request) and enabling a `myCustomAction`. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -35,4 +35,4 @@ class UsersDataTable extends DataTable } ``` -Take a look at `Yajra\Datatables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). +Take a look at `Yajra\DataTables\Services\DataTable` to see how to fetch and manipulate the data (functions `excel`, `csv`, `pdf`). diff --git a/buttons-export.md b/buttons-export.md index 43b1d9a..eef8400 100644 --- a/buttons-export.md +++ b/buttons-export.md @@ -10,7 +10,7 @@ Export button group includes `excel`, `csv` and `pdf` button. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -36,7 +36,7 @@ To enable exporting to excel, set `excel` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -62,7 +62,7 @@ To enable exporting to csv, set `csv` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -88,7 +88,7 @@ To enable exporting to pdf, set `pdf` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -114,7 +114,7 @@ To enable print button, set `print` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -140,7 +140,7 @@ To enable reset button, set `reset` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -166,7 +166,7 @@ To enable reload button, set `reload` on the buttons array. namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { diff --git a/buttons-extended.md b/buttons-extended.md index abd364f..2370477 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -35,7 +35,7 @@ TO ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ - return $dataTable->before(function (\Yajra\Datatables\Engines\BaseEngine $dataTable) { + return $dataTable->before(function (\Yajra\DataTables\Engines\BaseEngine $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); }) ->response(function (\Illuminate\Support\Collection $response) { @@ -43,7 +43,7 @@ Route::get('datatable', function(RolesDataTable $dataTable){ return $response; }) - ->withHtml(function(\Yajra\Datatables\Html\Builder $builder) { + ->withHtml(function(\Yajra\DataTables\Html\Builder $builder) { $builder->columns(['id', 'name', 'etc...']); }) ->with('key', 'value') diff --git a/buttons-installation.md b/buttons-installation.md index 23d3e02..35229aa 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -9,8 +9,8 @@ Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, - Yajra\Datatables\ButtonsServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\ButtonsServiceProvider::class, ], ``` diff --git a/buttons-starter.md b/buttons-starter.md index 1229484..d3da943 100644 --- a/buttons-starter.md +++ b/buttons-starter.md @@ -15,7 +15,7 @@ Update `UsersDataTable` class and set the columns and parameters needed to rende namespace App\DataTables; use App\User; -use Yajra\Datatables\Services\DataTable; +use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { @@ -73,4 +73,4 @@ Our `users.index` view located at `resources/views/users/index.blade.php`. {!! $dataTable->scripts() !!} @endpush -``` \ No newline at end of file +``` diff --git a/edit-column.md b/edit-column.md index 86463c6..c0e0137 100644 --- a/edit-column.md +++ b/edit-column.md @@ -6,12 +6,12 @@ You can edit a column on your response by using `editColumn` api. ## Edit Column with Blade Syntax ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->editColumn('name', 'Hi {{$name}}!') ->make(true); }); @@ -21,12 +21,12 @@ Route::get('user-data', function() { ## Edit Column with Closure ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->editColumn('name', function(User $user) { return 'Hi ' . $user->name . '!'; }) @@ -40,12 +40,12 @@ Route::get('user-data', function() { > {tip} You can use view to render your added column by passing the view path as the second argument on `editColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->editColumn('name', 'users.datatables.into') ->make(true); }); diff --git a/engine-collection.md b/engine-collection.md index 9aea44b..e977dff 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -1,13 +1,13 @@ # Collection Data Source You may use Laravel's Collection as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. +You can look at `Yajra\DataTables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. ## Collection via Factory ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $collection = collect([ @@ -16,7 +16,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return Datatables::of($collection)->make(true); + return DataTables::of($collection)->make(true); }); ``` @@ -24,7 +24,7 @@ Route::get('user-data', function() { ## Collection via Facade ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $collection = collect([ @@ -33,7 +33,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return Datatables::queryBuilder($collection)->make(true); + return DataTables::queryBuilder($collection)->make(true); }); ``` @@ -41,9 +41,9 @@ Route::get('user-data', function() { ## Collection via Dependency Injection ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $datatables) { $collection = collect([ ['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Jane'], diff --git a/engine-eloquent.md b/engine-eloquent.md index baafbc2..b4787a6 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -1,18 +1,18 @@ # Eloquent Data Source You may use Laravel's Eloquent Model as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. +You can look at `Yajra\DataTables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. ## Eloquent via Factory ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::of($model)->make(true); + return DataTables::of($model)->make(true); }); ``` @@ -20,12 +20,12 @@ Route::get('user-data', function() { ## Eloquent via Facade ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model)->make(true); + return DataTables::eloquent($model)->make(true); }); ``` @@ -33,9 +33,9 @@ Route::get('user-data', function() { ## Eloquent via Dependency Injection ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $datatables) { $model = App\User::query(); return $datatables->eloquent($model)->make(true); diff --git a/engine-query.md b/engine-query.md index e013a70..42ed66b 100644 --- a/engine-query.md +++ b/engine-query.md @@ -1,19 +1,19 @@ # Query Builder Data Source You may use Laravel's Query Builder as data source for your dataTables. -You can look at `Yajra\Datatables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. +You can look at `Yajra\DataTables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. ## Query Builder via Factory ```php use DB; -use Datatables; +use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return Datatables::of($query)->make(true); + return DataTables::of($query)->make(true); }); ``` @@ -22,12 +22,12 @@ Route::get('user-data', function() { ```php use DB; -use Datatables; +use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return Datatables::queryBuilder($query)->make(true); + return DataTables::queryBuilder($query)->make(true); }); ``` @@ -36,9 +36,9 @@ Route::get('user-data', function() { ```php use DB; -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('user-data', function(Datatables $datatables) { +Route::get('user-data', function(DataTables $datatables) { $query = DB::table('users'); return $datatables->queryBuilder($query)->make(true); diff --git a/error-handler.md b/error-handler.md index 4d812de..6ff5ab2 100644 --- a/error-handler.md +++ b/error-handler.md @@ -31,7 +31,7 @@ If set to `null`, the actual exception message will be used on error response. ## THROW Error -If set to `'throw'`, the package will throw a `\Yajra\Datatables\Exception`. +If set to `'throw'`, the package will throw a `\Yajra\DataTables\Exception`. You can then use your custom error handler if needed. **Example Error Handler** @@ -48,7 +48,7 @@ Update `app\Exceptions\Handler.php` and register dataTables error exception hand */ public function render($request, Exception $exception) { - if ($exception instanceof \Yajra\Datatables\Exception) { + if ($exception instanceof \Yajra\DataTables\Exception) { return response([ 'draw' => 0, 'recordsTotal' => 0, diff --git a/filter-column.md b/filter-column.md index eb1c2a7..1ddb296 100644 --- a/filter-column.md +++ b/filter-column.md @@ -4,7 +4,7 @@ In some cases, we need to implement a custom search for a specific column. To achieve this, you can use `filterColumn` api. ```php -use Datatables; +use DataTables; use DB; Route::get('user-data', function() { @@ -16,7 +16,7 @@ Route::get('user-data', function() { 'updated_at', ]); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filterColumn('fullname', function($query, $keyword) { $sql = "CONCAT(users.first_name,'-',users.last_name) like ?"; $query->whereRaw($sql, ["%{$keyword}%"]); diff --git a/general-settings.md b/general-settings.md index f1cac2f..cbf7493 100644 --- a/general-settings.md +++ b/general-settings.md @@ -47,9 +47,9 @@ This is where you can register your custom datatables engine. ```php 'engines' => [ - 'eloquent' => Yajra\Datatables\Engines\EloquentEngine::class, - 'query' => Yajra\Datatables\Engines\QueryBuilderEngine::class, - 'collection' => Yajra\Datatables\Engines\CollectionEngine::class, + 'eloquent' => Yajra\DataTables\Engines\EloquentEngine::class, + 'query' => Yajra\DataTables\Engines\QueryBuilderEngine::class, + 'collection' => Yajra\DataTables\Engines\CollectionEngine::class, // add your custom engine ], ``` diff --git a/html-builder-ajax.md b/html-builder-ajax.md index 3954330..92424d5 100644 --- a/html-builder-ajax.md +++ b/html-builder-ajax.md @@ -20,7 +20,7 @@ When the attribute passed is a `string`. The builder will treat this as the `URL $builder->ajax(route('users.data')); ``` -> {tip} Setting ajax to `null` or `empty string` will use the current url where Datatables was used. +> {tip} Setting ajax to `null` or `empty string` will use the current url where DataTables was used. **Array Attributes** diff --git a/html-builder-column.md b/html-builder-column.md index 7dd9748..ab21bf4 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -26,7 +26,7 @@ You also need to look at [`datatables.net`](https://datatables.net/reference/opt ### Name (Optional) Name attribute represents the `column` name from your data source. -Datatables will use this attribute when performing search and ordering functions. +DataTables will use this attribute when performing search and ordering functions. > {tip} If not set, `name` attribute will automatically be set to same value as `data` attribute. diff --git a/html-builder-index.md b/html-builder-index.md index 8cf4690..9179154 100644 --- a/html-builder-index.md +++ b/html-builder-index.md @@ -19,4 +19,4 @@ The default attributes of index column are: ]; ``` -The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `Datatables`. \ No newline at end of file +The `addIndex` api should be used along with [`addIndexColumn`](/docs/{{package}}/{{version}}/index-column) of `DataTables`. diff --git a/html-builder-macro.md b/html-builder-macro.md index 52fcb5a..e7f4ce4 100644 --- a/html-builder-macro.md +++ b/html-builder-macro.md @@ -4,8 +4,8 @@ You can extend DataTables HTML Builder using `macro`. ## Example macro: ```php -use Yajra\Datatables\Html\Builder; -use Yajra\Datatables\Html\Column; +use Yajra\DataTables\Html\Builder; +use Yajra\DataTables\Html\Column; Builder::macro('addEditColumn', function () { $attributes = [ @@ -28,4 +28,4 @@ Builder::macro('addEditColumn', function () { $builder = new Builder; $builder->addEditColumn()->ajax()->parameters([]); -``` \ No newline at end of file +``` diff --git a/html-builder-table.md b/html-builder-table.md index d57a894..25289b9 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -8,12 +8,12 @@ Table api accepts two parameters: `$builder->table(array $attributes, $footer = ## Table Example with Footer ```php -use Datatables; -use Yajra\Datatables\Html\Builder; +use DataTables; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return Datatables::of(User::query())->make(true); + return DataTables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-builder.md b/html-builder.md index 3b663c2..4e12936 100644 --- a/html-builder.md +++ b/html-builder.md @@ -1,6 +1,6 @@ # Html Builder -Datatables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. +DataTables has a built-in html builder that you can use to automatically generate your table mark-up and javascripts declarations. ## Html Builder via Dependency Injection @@ -8,7 +8,7 @@ Datatables has a built-in html builder that you can use to automatically generat You can use the `Builder` class by using Dependency Injection. ```php -use Yajra\Datatables\Html\Builder; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { }); @@ -24,12 +24,12 @@ Route::get('users', function() { ``` -## Html Builder from Datatables instance +## Html Builder from DataTables instance ```php -use Yajra\Datatables\Datatables; +use Yajra\DataTables\DataTables; -Route::get('users', function(Datatables $dataTable) { +Route::get('users', function(DataTables $dataTable) { $builder = $dataTable->getHtmlBuilder(); }); ``` @@ -38,12 +38,12 @@ Route::get('users', function(Datatables $dataTable) { ## Html Builder Example ```php -use Datatables; -use Yajra\Datatables\Html\Builder; +use DataTables; +use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return Datatables::of(User::query())->make(true); + return DataTables::of(User::query())->make(true); } $html = $builder->columns([ diff --git a/html-installation.md b/html-installation.md index d8061b1..75bf473 100644 --- a/html-installation.md +++ b/html-installation.md @@ -11,8 +11,8 @@ Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, - Yajra\Datatables\HtmlServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\HtmlServiceProvider::class, ], ``` diff --git a/index-column.md b/index-column.md index 396b499..09a84e4 100644 --- a/index-column.md +++ b/index-column.md @@ -4,16 +4,16 @@ In some cases, you need to track the index of the records on your response. To achieve this, you can add an index column on your response by using `addIndexColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addIndexColumn() ->make(true); }); ``` Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. -The default index column name is `DT_Row_Index` \ No newline at end of file +The default index column name is `DT_Row_Index` diff --git a/installation.md b/installation.md index f704375..b1650d3 100644 --- a/installation.md +++ b/installation.md @@ -2,7 +2,7 @@ - [Installation](#installation) - [Requirements](#requirements) - - [Installing Laravel-Datatables](#installing-laravel-datatables-oracle) + - [Installing Laravel-DataTables](#installing-laravel-datatables-oracle) - [Configuration](#configuration) @@ -15,9 +15,9 @@ - [jQuery DataTables v1.10.x](http://datatables.net/) -### Installing Laravel Datatables +### Installing Laravel DataTables -Laravel Datatables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-datatables-oracle). +Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-datatables-oracle). Run the following command in your project to get the latest version of the package: @@ -33,7 +33,7 @@ Open the file ```config/app.php``` and then add following service provider. ```php 'providers' => [ // ... - Yajra\Datatables\DatatablesServiceProvider::class, + Yajra\DataTables\DataTablesServiceProvider::class, ], ``` diff --git a/manual-order.md b/manual-order.md index c64b98d..b752682 100644 --- a/manual-order.md +++ b/manual-order.md @@ -1,15 +1,15 @@ # Manual Order -You may optionally disable the default ordering function of Datatables and write you own using `order` api. +You may optionally disable the default ordering function of DataTables and write you own using `order` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->order(function ($query) { if (request()->has('name')) { $query->orderBy('name', 'asc'); @@ -21,4 +21,4 @@ Route::get('user-data', function() { }) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/manual-search.md b/manual-search.md index 167c7d6..8a5e3a2 100644 --- a/manual-search.md +++ b/manual-search.md @@ -7,12 +7,12 @@ To achieve this, you can use the `filter` api. ## Manual Searching without Global Search ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); @@ -32,12 +32,12 @@ Route::get('user-data', function() { > {tip} To enable global search with filter api, just set the 2nd argument to `true`. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { $query->where('name', 'like', "%{request('name')}%"); diff --git a/only-trashed.md b/only-trashed.md index fbbed15..ea836b7 100644 --- a/only-trashed.md +++ b/only-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Only Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include only trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include only trashed records in the results. To achieve this, we can use `onlyTrashed` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::onlyTrashed()->query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->onlyTrashed() ->make(true); }); -``` \ No newline at end of file +``` diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index d2fc0ef..ada5986 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -1,14 +1,14 @@ # Order by NULLS LAST -This api will set Datatables to perform ordering with `NULLS LAST` option. +This api will set DataTables to perform ordering with `NULLS LAST` option. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderByNullsLast() ->make(true); }); diff --git a/order-column.md b/order-column.md index 5d19648..1f41f9c 100644 --- a/order-column.md +++ b/order-column.md @@ -7,13 +7,13 @@ In some cases, you may want to use a custom order sql for a specific column. To In this example, we will order the column name with nulls as last result. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderColumn('name', '-name $1') ->make(true); }); -``` \ No newline at end of file +``` diff --git a/order-columns.md b/order-columns.md index 3fef0f1..45075bb 100644 --- a/order-columns.md +++ b/order-columns.md @@ -11,13 +11,13 @@ In some cases, you may want to use a custom order sql for a set of columns. To a In this example, we will order the column name with nulls as last result. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->orderColumns(['name', 'email'], '-:column $1') ->make(true); }); -``` \ No newline at end of file +``` diff --git a/query-builder.md b/query-builder.md index daa9c52..69ac5d6 100644 --- a/query-builder.md +++ b/query-builder.md @@ -1,16 +1,16 @@ # Query Builder Extension -Datatables instance allows you to proxy a database query call. +DataTables instance allows you to proxy a database query call. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - $dataTable = Datatables::eloquent($model); + $dataTable = DataTables::eloquent($model); $dataTable->where('company_id', 2); return $dataTable->make(true); }); -``` \ No newline at end of file +``` diff --git a/raw-columns.md b/raw-columns.md index e612e3f..aa09353 100644 --- a/raw-columns.md +++ b/raw-columns.md @@ -5,12 +5,12 @@ In cases where you want to render an html content, please use `rawColumns` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('link', 'Html Column') ->addColumn('action', 'path.to.view') ->rawColumns(['link', 'action']) diff --git a/readme.md b/readme.md index 084b4be..b2985c7 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ -# Laravel Datatables Documentation +# Laravel DataTables Documentation ## Contribution Guidelines If you are submitting documentation for the **current stable release**, submit it to the corresponding branch. -For example, documentation for Laravel Datatables 6.0 would be submitted to the `6.0` branch. -Documentation intended for the next release of Laravel Datatables should be submitted to the `master` branch. \ No newline at end of file +For example, documentation for Laravel DataTables 6.0 would be submitted to the `6.0` branch. +Documentation intended for the next release of Laravel DataTables should be submitted to the `master` branch. diff --git a/regex.md b/regex.md index 9c5774e..02b1000 100644 --- a/regex.md +++ b/regex.md @@ -1,6 +1,6 @@ # Regex Searching -Datatables has the ability to perform search using regular expressions. +DataTables has the ability to perform search using regular expressions. > Regex search only works and tested on the following Laravel DB drivers: MySQL, SQLite and Oracle. @@ -22,4 +22,4 @@ $('#example').dataTable({ "regex": true } }); -``` \ No newline at end of file +``` diff --git a/relationships.md b/relationships.md index 91f1b29..d6442a4 100644 --- a/relationships.md +++ b/relationships.md @@ -1,17 +1,17 @@ # Eager Loading Relationships -`Datatables` support searching and sorting of eager loaded relationships when using `Eloquent`. +`DataTables` support searching and sorting of eager loaded relationships when using `Eloquent`. In this example, I will show you how to setup a eager loading search using `EloquentEngine`. To enable search, we need to eager load the relationship we intend to use using Laravel's `User::with('posts')` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::with('posts'); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('posts', function (User $user) { return $user->posts->map(function($post) { return str_limit($post->title, 30, '...'); diff --git a/releases.md b/releases.md index 6659c2f..f12c3a7 100644 --- a/releases.md +++ b/releases.md @@ -1,25 +1,25 @@ # Release Notes -- [Laravel Datatables 7.0](#7.0) +- [Laravel DataTables 7.0](#7.0) -## Laravel Datatables 7.0 +## Laravel DataTables 7.0 -Laravel Datatables 7.0 splits Laravel Datatables 6.x into a main package and plugins packages for more flexibile and pluggable design. +Laravel DataTables 7.0 splits Laravel DataTables 6.x into a main package and plugins packages for more flexibile and pluggable design. ### Buttons Plugin -On Laravel Datatables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. +On Laravel DataTables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues/832) which actually makes sense since not all users are using the export functionality. ### DomPDF -`DomPDF` dependency is now optional on Laravel Datatables 7.0 and was transferred to Buttons plugin. +`DomPDF` dependency is now optional on Laravel DataTables 7.0 and was transferred to Buttons plugin. And the `Buttons` plugin will now give you a choice to install it or not. This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. ### Other Changes #### Request property -`Datatables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. +`DataTables` `request` property is now set as `protected`. To access the request instance, use the getter method `getRequest()`. ```php $dataTable = Datatable::of(User::query()); diff --git a/remove-column.md b/remove-column.md index a5a8751..71fbec7 100644 --- a/remove-column.md +++ b/remove-column.md @@ -3,12 +3,12 @@ You can remove a column on your response by using `removeColumn` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->removeColumn('password') ->make(true); }); diff --git a/response-array.md b/response-array.md index f462000..59270ee 100644 --- a/response-array.md +++ b/response-array.md @@ -1,14 +1,14 @@ # Array Response -Array response is the default response of Datatables. +Array response is the default response of DataTables. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(); }); @@ -28,4 +28,4 @@ Route::get('user-data', function() { [120, "Adeline Mayert-name", "rice.elian@abshire.com", "2016-07-31 23:25:50", "2016-07-31 23:25:50"] ] } -``` \ No newline at end of file +``` diff --git a/response-fractal-serializer.md b/response-fractal-serializer.md index ac4ddc5..229e0da 100644 --- a/response-fractal-serializer.md +++ b/response-fractal-serializer.md @@ -1,16 +1,16 @@ # Fractal Transformer Serializer -You can set the serializer to be used by Datatables using `setSerializer` api. Serializer should be used with `setTransformer` api. +You can set the serializer to be used by DataTables using `setSerializer` api. Serializer should be used with `setTransformer` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTransformer(new App\Transformers\UserTransformer) ->setSerializer(new App\Serializers\CustomSerializer) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/response-fractal.md b/response-fractal.md index 6b015e3..5d15ead 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -4,13 +4,13 @@ When using tranformer, all response manipulations must be done via transformer. Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, etc... should be avoided when using fractal. ```php -use Datatables; +use DataTables; use App\Transformers\UserTransformer; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTransformer(new UserTransformer) ->make(true); }); @@ -54,4 +54,4 @@ class UserTransformer extends TransformerAbstract return $this->collection($posts, new PostTransformer); } } -``` \ No newline at end of file +``` diff --git a/response-object.md b/response-object.md index aa6d340..4e8e966 100644 --- a/response-object.md +++ b/response-object.md @@ -1,14 +1,14 @@ # Object Response -To convert the response of Datatables to an object, just pass `true` on `make` api. +To convert the response of DataTables to an object, just pass `true` on `make` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') ->make(true); }); @@ -40,4 +40,4 @@ Route::get('user-data', function() { "superior_id": 1 }] } -``` \ No newline at end of file +``` diff --git a/response-with.md b/response-with.md index db1967d..4fdad8c 100644 --- a/response-with.md +++ b/response-with.md @@ -6,12 +6,12 @@ You can add additional server data on your response by using `with` api. ## Adding response using key and value ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->with('posts', 100) ->with('comments', 20) ->make(true); @@ -22,12 +22,12 @@ Route::get('user-data', function() { ## Adding response using array ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->with([ 'posts' => 100, 'comments' => 20, @@ -64,4 +64,4 @@ Route::get('user-data', function() { "posts": 100, "comments": 20 } -``` \ No newline at end of file +``` diff --git a/set-total-records.md b/set-total-records.md index 4d907c1..3c59d39 100644 --- a/set-total-records.md +++ b/set-total-records.md @@ -1,16 +1,16 @@ # Set Total Records -In some cases, we need to manually set the total records of our `Datatables` and skip its internal counting functionality. +In some cases, we need to manually set the total records of our `DataTables` and skip its internal counting functionality. To achieve this, we can use `setTotalRecords($count)` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->setTotalRecords(100) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/skip-paging.md b/skip-paging.md index f3fdb48..c76c1ad 100644 --- a/skip-paging.md +++ b/skip-paging.md @@ -1,15 +1,15 @@ # Skip Paging -To skip paging of `Datatables`, we can use `skipPaging` api or just set `paging: false` on our javascript. +To skip paging of `DataTables`, we can use `skipPaging` api or just set `paging: false` on our javascript. ## Using PHP ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::withTrashed()->query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->skipPaging() ->make(true); }); @@ -27,4 +27,4 @@ $(document).ready(function() { }); }); -``` \ No newline at end of file +``` diff --git a/smart-search.md b/smart-search.md index df3ab5a..170918f 100644 --- a/smart-search.md +++ b/smart-search.md @@ -1,16 +1,16 @@ # Runtime Smart Search -You can optionally enable/disable Datatables smart search feature by using `smart` api by passing `true` or `false` as the argument. +You can optionally enable/disable DataTables smart search feature by using `smart` api by passing `true` or `false` as the argument. Default argument value is `true`. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->smart(false) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/whitelist.md b/whitelist.md index 39578df..bfffd12 100644 --- a/whitelist.md +++ b/whitelist.md @@ -3,13 +3,13 @@ Sorting and searching will only work on columns explicitly defined as whitelist. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->whitelist(['name', 'email']) ->make(true); }); -``` \ No newline at end of file +``` diff --git a/with-trashed.md b/with-trashed.md index 64c1aee..44f8407 100644 --- a/with-trashed.md +++ b/with-trashed.md @@ -1,16 +1,16 @@ # Eloquent Model With Trashed -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `Datatables` to include trashed records in the results. +When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include trashed records in the results. To achieve this, we can use `withTrashed` api. ```php -use Datatables; +use DataTables; Route::get('user-data', function() { $model = App\User::query()->withTrashed(); - return Datatables::eloquent($model) + return DataTables::eloquent($model) ->withTrashed() ->make(true); }); -``` \ No newline at end of file +``` diff --git a/xss.md b/xss.md index 56792a5..ca0d35c 100644 --- a/xss.md +++ b/xss.md @@ -8,7 +8,7 @@ Since v7.0, all dataTable response are encoded to prevent XSS attack. In case yo ## Raw Columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->rawColumns(['name', 'action']) ->make(true); ``` @@ -19,7 +19,7 @@ return Datatables::eloquent(Role::select()) ## Escape selected fields ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns(['name']) ->make(true); ``` @@ -27,7 +27,7 @@ return Datatables::eloquent(Role::select()) ## Escape all columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns() ->make(true); ``` @@ -36,7 +36,7 @@ return Datatables::eloquent(Role::select()) ## Remove escaping of all columns ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns([]) ->make(true); ``` @@ -45,7 +45,7 @@ return Datatables::eloquent(Role::select()) ## Escape by output index ```php -return Datatables::eloquent(Role::select()) +return DataTables::eloquent(Role::select()) ->escapeColumns([0]) ->make(); - ``` \ No newline at end of file + ``` From 495d963f535460e95205f8ff54d4a47cb6ba323a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:38:22 +0800 Subject: [PATCH 069/264] Fix DataTableAbstract. --- buttons-console.md | 4 ++-- buttons-extended.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buttons-console.md b/buttons-console.md index f13880b..7e88422 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -31,7 +31,7 @@ class PostsDataTable extends DataTable /** * Build DataTable class. * - * @return \Yajra\DataTables\Engines\BaseEngine + * @return \Yajra\DataTables\DataTableAbstract */ public function dataTable() { @@ -117,7 +117,7 @@ class PostsDataTable extends DataTable /** * Build DataTable class. * - * @return \Yajra\DataTables\Engines\BaseEngine + * @return \Yajra\DataTables\DataTableAbstract */ public function dataTable() { diff --git a/buttons-extended.md b/buttons-extended.md index 2370477..7da96c5 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -35,7 +35,7 @@ TO ## Quick Example: ```php Route::get('datatable', function(RolesDataTable $dataTable){ - return $dataTable->before(function (\Yajra\DataTables\Engines\BaseEngine $dataTable) { + return $dataTable->before(function (\Yajra\DataTables\DataTableAbstract $dataTable) { return $dataTable->addColumn('test', 'added inside controller'); }) ->response(function (\Illuminate\Support\Collection $response) { From 79b0582f07ba6e1079bbfc8419640e9791f8dc67 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:41:54 +0800 Subject: [PATCH 070/264] Bump html & buttons version. --- buttons-installation.md | 2 +- html-installation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buttons-installation.md b/buttons-installation.md index 35229aa..ef6dd6c 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^2.0` +`composer require yajra/laravel-datatables-buttons:^3.0` Open the file ```config/app.php``` and then add following service provider. diff --git a/html-installation.md b/html-installation.md index 75bf473..ab5c023 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,7 +4,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^2.0` +`composer require yajra/laravel-datatables-html:^3.0` Open the file ```config/app.php``` and then add following service provider. From aafedf054a2bb42c9e9527abdde0a5b7688eb967 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 12:42:51 +0800 Subject: [PATCH 071/264] Bump core to 8.0 --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index b1650d3..616169b 100644 --- a/installation.md +++ b/installation.md @@ -22,7 +22,7 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ``` -composer require yajra/laravel-datatables-oracle:^7.0 +composer require yajra/laravel-datatables-oracle:^8.0 ``` From 5bdd7e63f829313bec32ae1e572c7a85f5aa0629 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:11:56 +0800 Subject: [PATCH 072/264] Use 5.5 --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 616169b..784fe26 100644 --- a/installation.md +++ b/installation.md @@ -11,7 +11,7 @@ ### Requirements -- [Laravel 5.4](https://github.com/laravel/framework) +- [Laravel 5.5](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) From b0a82fdf2838768b8336f9d6c9d62fe3a136ca1f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:16:13 +0800 Subject: [PATCH 073/264] Add all-in-one installer doc. --- installation.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/installation.md b/installation.md index 784fe26..e58f117 100644 --- a/installation.md +++ b/installation.md @@ -14,19 +14,26 @@ - [Laravel 5.5](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) - + ### Installing Laravel DataTables Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/00-intro.md). More details about this package in Composer can be found [here](https://packagist.org/packages/yajra/laravel-datatables-oracle). Run the following command in your project to get the latest version of the package: -``` +```bash composer require yajra/laravel-datatables-oracle:^8.0 ``` +If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. + +```bash +composer require yajra/laravel-datatables:^1.0 +``` + ### Configuration +> This step is optional if you are using Laravel 5.5 Open the file ```config/app.php``` and then add following service provider. From f8dba3d91960035d9ebddcedbad65eaceb111d5c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:18:11 +0800 Subject: [PATCH 074/264] Fix link. --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index e58f117..085d2ba 100644 --- a/installation.md +++ b/installation.md @@ -2,7 +2,7 @@ - [Installation](#installation) - [Requirements](#requirements) - - [Installing Laravel-DataTables](#installing-laravel-datatables-oracle) + - [Installing Laravel-DataTables](#installing-laravel-datatables) - [Configuration](#configuration) From 8fe1ece96a735e0b33dcedd10c1674aac9a7d49a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:20:08 +0800 Subject: [PATCH 075/264] Use new toJson() method. --- add-column.md | 8 ++++---- blacklist.md | 2 +- buttons-extended.md | 4 ++-- edit-column.md | 6 +++--- engine-collection.md | 8 ++++---- engine-eloquent.md | 8 ++++---- engine-query.md | 8 ++++---- filter-column.md | 2 +- html-builder-table.md | 2 +- html-builder.md | 2 +- index-column.md | 2 +- manual-order.md | 2 +- manual-search.md | 4 ++-- only-trashed.md | 2 +- order-by-nulls-last.md | 2 +- order-column.md | 2 +- order-columns.md | 2 +- query-builder.md | 2 +- raw-columns.md | 2 +- relationships.md | 2 +- remove-column.md | 2 +- response-fractal-serializer.md | 2 +- response-fractal.md | 2 +- response-object.md | 2 +- response-with.md | 4 ++-- set-total-records.md | 2 +- skip-paging.md | 2 +- smart-search.md | 2 +- upgrade.md | 2 +- whitelist.md | 2 +- with-trashed.md | 2 +- xss.md | 8 ++++---- 32 files changed, 52 insertions(+), 52 deletions(-) diff --git a/add-column.md b/add-column.md index e9cfb26..01dcaf3 100644 --- a/add-column.md +++ b/add-column.md @@ -13,7 +13,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') - ->make(true); + ->toJson(); }); ``` @@ -30,7 +30,7 @@ Route::get('user-data', function() { ->addColumn('intro', function(User $user) { return 'Hi ' . $user->name . '!'; }) - ->make(true); + ->toJson(); }); ``` @@ -47,7 +47,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addColumn('intro', 'users.datatables.intro') - ->make(true); + ->toJson(); }); ``` @@ -69,6 +69,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!', 2) - ->make(true); + ->toJson(); }); ``` diff --git a/blacklist.md b/blacklist.md index df25725..a7950a4 100644 --- a/blacklist.md +++ b/blacklist.md @@ -10,6 +10,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->blacklist(['password', 'name']) - ->make(true); + ->toJson(); }); ``` diff --git a/buttons-extended.md b/buttons-extended.md index 7da96c5..2811a86 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -8,7 +8,7 @@ We can now extend and reuse our DataTable class inside our controller by using ` ## Upgrading from v1.0 to v1.1 - Upgrade to `laravel-datatables-buttons:^1.1` - Rename `ajax()` method to `dataTable()` -- Remove `->make(true)` from the method chain. +- Remove `->toJson()` from the method chain. ```php public function ajax() @@ -16,7 +16,7 @@ We can now extend and reuse our DataTable class inside our controller by using ` return $this->datatables ->eloquent($this->query()) ->addColumn('action', 'path.to.action.view') - ->make(true) + ->toJson() } ``` diff --git a/edit-column.md b/edit-column.md index c0e0137..d778e78 100644 --- a/edit-column.md +++ b/edit-column.md @@ -13,7 +13,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->editColumn('name', 'Hi {{$name}}!') - ->make(true); + ->toJson(); }); ``` @@ -30,7 +30,7 @@ Route::get('user-data', function() { ->editColumn('name', function(User $user) { return 'Hi ' . $user->name . '!'; }) - ->make(true); + ->toJson(); }); ``` @@ -47,7 +47,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->editColumn('name', 'users.datatables.into') - ->make(true); + ->toJson(); }); ``` diff --git a/engine-collection.md b/engine-collection.md index e977dff..b1b0a48 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -16,7 +16,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return DataTables::of($collection)->make(true); + return DataTables::of($collection)->toJson(); }); ``` @@ -33,7 +33,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return DataTables::queryBuilder($collection)->make(true); + return DataTables::queryBuilder($collection)->toJson(); }); ``` @@ -50,7 +50,7 @@ Route::get('user-data', function(DataTables $datatables) { ['id' => 3, 'name' => 'James'], ]); - return $datatables->queryBuilder($collection)->make(true); + return $datatables->queryBuilder($collection)->toJson(); }); ``` @@ -65,6 +65,6 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return app('datatables')->queryBuilder($collection)->make(true); + return app('datatables')->queryBuilder($collection)->toJson(); }); ``` diff --git a/engine-eloquent.md b/engine-eloquent.md index b4787a6..9b08c64 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -12,7 +12,7 @@ use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::of($model)->make(true); + return DataTables::of($model)->toJson(); }); ``` @@ -25,7 +25,7 @@ use DataTables; Route::get('user-data', function() { $model = App\User::query(); - return DataTables::eloquent($model)->make(true); + return DataTables::eloquent($model)->toJson(); }); ``` @@ -38,7 +38,7 @@ use Yajra\DataTables\DataTables; Route::get('user-data', function(DataTables $datatables) { $model = App\User::query(); - return $datatables->eloquent($model)->make(true); + return $datatables->eloquent($model)->toJson(); }); ``` @@ -48,6 +48,6 @@ Route::get('user-data', function(DataTables $datatables) { Route::get('user-data', function() { $model = App\User::query(); - return app('datatables')->eloquent($model)->make(true); + return app('datatables')->eloquent($model)->toJson(); }); ``` diff --git a/engine-query.md b/engine-query.md index 42ed66b..c986c88 100644 --- a/engine-query.md +++ b/engine-query.md @@ -13,7 +13,7 @@ use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return DataTables::of($query)->make(true); + return DataTables::of($query)->toJson(); }); ``` @@ -27,7 +27,7 @@ use DataTables; Route::get('user-data', function() { $query = DB::table('users'); - return DataTables::queryBuilder($query)->make(true); + return DataTables::queryBuilder($query)->toJson(); }); ``` @@ -41,7 +41,7 @@ use Yajra\DataTables\DataTables; Route::get('user-data', function(DataTables $datatables) { $query = DB::table('users'); - return $datatables->queryBuilder($query)->make(true); + return $datatables->queryBuilder($query)->toJson(); }); ``` @@ -53,6 +53,6 @@ use DB; Route::get('user-data', function() { $query = DB::table('users'); - return app('datatables')->queryBuilder($query)->make(true); + return app('datatables')->queryBuilder($query)->toJson(); }); ``` diff --git a/filter-column.md b/filter-column.md index 1ddb296..a0e9f88 100644 --- a/filter-column.md +++ b/filter-column.md @@ -21,6 +21,6 @@ Route::get('user-data', function() { $sql = "CONCAT(users.first_name,'-',users.last_name) like ?"; $query->whereRaw($sql, ["%{$keyword}%"]); }) - ->make(true); + ->toJson(); }); ``` diff --git a/html-builder-table.md b/html-builder-table.md index 25289b9..4069f36 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -13,7 +13,7 @@ use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return DataTables::of(User::query())->make(true); + return DataTables::of(User::query())->toJson(); } $html = $builder->columns([ diff --git a/html-builder.md b/html-builder.md index 4e12936..f8204f0 100644 --- a/html-builder.md +++ b/html-builder.md @@ -43,7 +43,7 @@ use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { if (request()->ajax()) { - return DataTables::of(User::query())->make(true); + return DataTables::of(User::query())->toJson(); } $html = $builder->columns([ diff --git a/index-column.md b/index-column.md index 09a84e4..8376046 100644 --- a/index-column.md +++ b/index-column.md @@ -11,7 +11,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addIndexColumn() - ->make(true); + ->toJson(); }); ``` diff --git a/manual-order.md b/manual-order.md index b752682..3d19851 100644 --- a/manual-order.md +++ b/manual-order.md @@ -19,6 +19,6 @@ Route::get('user-data', function() { $query->orderBy('email', 'desc'); } }) - ->make(true); + ->toJson(); }); ``` diff --git a/manual-search.md b/manual-search.md index 8a5e3a2..ce521b1 100644 --- a/manual-search.md +++ b/manual-search.md @@ -22,7 +22,7 @@ Route::get('user-data', function() { $query->where('email', 'like', "%{request('email')}%"); } }) - ->make(true); + ->toJson(); }); ``` @@ -47,6 +47,6 @@ Route::get('user-data', function() { $query->where('email', 'like', "%{request('email')}%"); } }, true) - ->make(true); + ->toJson(); }); ``` diff --git a/only-trashed.md b/only-trashed.md index ea836b7..a970d8e 100644 --- a/only-trashed.md +++ b/only-trashed.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->onlyTrashed() - ->make(true); + ->toJson(); }); ``` diff --git a/order-by-nulls-last.md b/order-by-nulls-last.md index ada5986..f3f713b 100644 --- a/order-by-nulls-last.md +++ b/order-by-nulls-last.md @@ -10,7 +10,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->orderByNullsLast() - ->make(true); + ->toJson(); }); ``` diff --git a/order-column.md b/order-column.md index 1f41f9c..711483d 100644 --- a/order-column.md +++ b/order-column.md @@ -14,6 +14,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->orderColumn('name', '-name $1') - ->make(true); + ->toJson(); }); ``` diff --git a/order-columns.md b/order-columns.md index 45075bb..aac5ae2 100644 --- a/order-columns.md +++ b/order-columns.md @@ -18,6 +18,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->orderColumns(['name', 'email'], '-:column $1') - ->make(true); + ->toJson(); }); ``` diff --git a/query-builder.md b/query-builder.md index 69ac5d6..d6b88da 100644 --- a/query-builder.md +++ b/query-builder.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { $dataTable = DataTables::eloquent($model); $dataTable->where('company_id', 2); - return $dataTable->make(true); + return $dataTable->toJson(); }); ``` diff --git a/raw-columns.md b/raw-columns.md index aa09353..cac479a 100644 --- a/raw-columns.md +++ b/raw-columns.md @@ -14,7 +14,7 @@ Route::get('user-data', function() { ->addColumn('link', 'Html Column') ->addColumn('action', 'path.to.view') ->rawColumns(['link', 'action']) - ->make(true); + ->toJson(); }); ``` diff --git a/relationships.md b/relationships.md index d6442a4..ab91039 100644 --- a/relationships.md +++ b/relationships.md @@ -17,7 +17,7 @@ Route::get('user-data', function() { return str_limit($post->title, 30, '...'); })->implode('
'); }) - ->make(true); + ->toJson(); }); ``` diff --git a/remove-column.md b/remove-column.md index 71fbec7..f0d2715 100644 --- a/remove-column.md +++ b/remove-column.md @@ -10,6 +10,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->removeColumn('password') - ->make(true); + ->toJson(); }); ``` diff --git a/response-fractal-serializer.md b/response-fractal-serializer.md index 229e0da..9adb198 100644 --- a/response-fractal-serializer.md +++ b/response-fractal-serializer.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->setTransformer(new App\Transformers\UserTransformer) ->setSerializer(new App\Serializers\CustomSerializer) - ->make(true); + ->toJson(); }); ``` diff --git a/response-fractal.md b/response-fractal.md index 5d15ead..f0a8b43 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -12,7 +12,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->setTransformer(new UserTransformer) - ->make(true); + ->toJson(); }); ``` diff --git a/response-object.md b/response-object.md index 4e8e966..84b13b5 100644 --- a/response-object.md +++ b/response-object.md @@ -10,7 +10,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') - ->make(true); + ->toJson(); }); ``` diff --git a/response-with.md b/response-with.md index 4fdad8c..e4fe5d6 100644 --- a/response-with.md +++ b/response-with.md @@ -14,7 +14,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->with('posts', 100) ->with('comments', 20) - ->make(true); + ->toJson(); }); ``` @@ -32,7 +32,7 @@ Route::get('user-data', function() { 'posts' => 100, 'comments' => 20, ]) - ->make(true); + ->toJson(); }); ``` diff --git a/set-total-records.md b/set-total-records.md index 3c59d39..e093baf 100644 --- a/set-total-records.md +++ b/set-total-records.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->setTotalRecords(100) - ->make(true); + ->toJson(); }); ``` diff --git a/skip-paging.md b/skip-paging.md index c76c1ad..078403f 100644 --- a/skip-paging.md +++ b/skip-paging.md @@ -11,7 +11,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->skipPaging() - ->make(true); + ->toJson(); }); ``` diff --git a/smart-search.md b/smart-search.md index 170918f..759ffb5 100644 --- a/smart-search.md +++ b/smart-search.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->smart(false) - ->make(true); + ->toJson(); }); ``` diff --git a/upgrade.md b/upgrade.md index 2fbea02..ff65f53 100644 --- a/upgrade.md +++ b/upgrade.md @@ -158,7 +158,7 @@ All columns are now escaped by default to protect us from XSS attack. To allow c Datatables::of(User::query()) ->addColumn('href', 'Html Content') ->rawColumns(['href']) - ->make(true); + ->toJson(); ``` diff --git a/whitelist.md b/whitelist.md index bfffd12..fe5ce12 100644 --- a/whitelist.md +++ b/whitelist.md @@ -10,6 +10,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->whitelist(['name', 'email']) - ->make(true); + ->toJson(); }); ``` diff --git a/with-trashed.md b/with-trashed.md index 44f8407..590c819 100644 --- a/with-trashed.md +++ b/with-trashed.md @@ -11,6 +11,6 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->withTrashed() - ->make(true); + ->toJson(); }); ``` diff --git a/xss.md b/xss.md index ca0d35c..a8e125f 100644 --- a/xss.md +++ b/xss.md @@ -10,7 +10,7 @@ Since v7.0, all dataTable response are encoded to prevent XSS attack. In case yo ```php return DataTables::eloquent(Role::select()) ->rawColumns(['name', 'action']) - ->make(true); + ->toJson(); ``` # Other XSS methods @@ -21,7 +21,7 @@ return DataTables::eloquent(Role::select()) ```php return DataTables::eloquent(Role::select()) ->escapeColumns(['name']) - ->make(true); + ->toJson(); ``` ## Escape all columns @@ -29,7 +29,7 @@ return DataTables::eloquent(Role::select()) ```php return DataTables::eloquent(Role::select()) ->escapeColumns() - ->make(true); + ->toJson(); ``` @@ -38,7 +38,7 @@ return DataTables::eloquent(Role::select()) ```php return DataTables::eloquent(Role::select()) ->escapeColumns([]) - ->make(true); + ->toJson(); ``` From 70f430e30db140b0224fe3aee693938c5becb175 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:25:11 +0800 Subject: [PATCH 076/264] Update DataTables new classes. --- documentation.md | 2 +- engine-collection.md | 14 +++++++++++++- engine-eloquent.md | 17 +++++++++++++++-- engine-query.md | 14 +++++++++++++- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/documentation.md b/documentation.md index 5801f76..0ab8454 100644 --- a/documentation.md +++ b/documentation.md @@ -16,7 +16,7 @@ - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - [Error Handler](/docs/{{package}}/{{version}}/error-handler) -- Engines & Data Sources +- DataTables Classes - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) - [Query Builder](/docs/{{package}}/{{version}}/engine-query) - [Collection](/docs/{{package}}/{{version}}/engine-collection) diff --git a/engine-collection.md b/engine-collection.md index b1b0a48..8564fd7 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -1,7 +1,7 @@ # Collection Data Source You may use Laravel's Collection as data source for your dataTables. -You can look at `Yajra\DataTables\Enginges\CollectionEngine` class which handles the conversion of your Collection into a readbale DataTable API response. +You can look at `Yajra\DataTables\CollectionDataTable` class which handles the conversion of your Collection into a readbale DataTable API response. ## Collection via Factory @@ -68,3 +68,15 @@ Route::get('user-data', function() { return app('datatables')->queryBuilder($collection)->toJson(); }); ``` + + +## CollectionDataTable new Instance + +```php +use Yajra\DataTables\CollectionDataTable; + +Route::get('user-data', function() { + $model = App\User::query(); + + return (new CollectionDataTable($model))->toJson(); +}); diff --git a/engine-eloquent.md b/engine-eloquent.md index 9b08c64..5e20a17 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -1,7 +1,7 @@ # Eloquent Data Source You may use Laravel's Eloquent Model as data source for your dataTables. -You can look at `Yajra\DataTables\Enginges\EloquentEngine` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. +You can look at `Yajra\DataTables\EloquentDataTable` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. ## Eloquent via Factory @@ -45,9 +45,22 @@ Route::get('user-data', function(DataTables $datatables) { ## Eloquent via IoC ```php +Route::get('user-data', function() { + $model = App\User::query(); + + return app('datatables')->eloquent($model)->toJson(); +}); +``` + + +## EloquentDataTable new Instance + +```php +use Yajra\DataTables\EloquentDataTable; + Route::get('user-data', function() { $model = App\User::query(); - return app('datatables')->eloquent($model)->toJson(); + return (new EloquentDataTable($model))->toJson(); }); ``` diff --git a/engine-query.md b/engine-query.md index c986c88..cfbed1d 100644 --- a/engine-query.md +++ b/engine-query.md @@ -1,7 +1,7 @@ # Query Builder Data Source You may use Laravel's Query Builder as data source for your dataTables. -You can look at `Yajra\DataTables\Enginges\QueryBuilderEngine` class which handles the conversion of your Query Builder into a readbale DataTable API response. +You can look at `Yajra\DataTables\QueryDataTable` class which handles the conversion of your Query Builder into a readbale DataTable API response. ## Query Builder via Factory @@ -56,3 +56,15 @@ Route::get('user-data', function() { return app('datatables')->queryBuilder($query)->toJson(); }); ``` + + +## QueryDataTable new Instance + +```php +use Yajra\DataTables\QueryDataTable; + +Route::get('user-data', function() { + $model = App\User::query(); + + return (new QueryDataTable($model))->toJson(); +}); From f64955a07591b63124d786db81d251cea42d912e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:26:30 +0800 Subject: [PATCH 077/264] Fix collection source. --- engine-collection.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine-collection.md b/engine-collection.md index 8564fd7..566805a 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -76,7 +76,7 @@ Route::get('user-data', function() { use Yajra\DataTables\CollectionDataTable; Route::get('user-data', function() { - $model = App\User::query(); + $collection = App\User::all(); - return (new CollectionDataTable($model))->toJson(); + return (new CollectionDataTable($collection))->toJson(); }); From 501e53c56fc70bd430e20bb62d8e221aed316760 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:26:54 +0800 Subject: [PATCH 078/264] Fix query source. --- engine-query.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine-query.md b/engine-query.md index cfbed1d..09663f1 100644 --- a/engine-query.md +++ b/engine-query.md @@ -64,7 +64,7 @@ Route::get('user-data', function() { use Yajra\DataTables\QueryDataTable; Route::get('user-data', function() { - $model = App\User::query(); + $query = DB::table('users'); - return (new QueryDataTable($model))->toJson(); + return (new QueryDataTable($query))->toJson(); }); From 1a54392d4e03ae62f703b31c548e3d9f3979a958 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 7 Sep 2017 17:29:01 +0800 Subject: [PATCH 079/264] Add optional notes. --- buttons-installation.md | 3 +++ html-installation.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/buttons-installation.md b/buttons-installation.md index ef6dd6c..87e80a8 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -4,6 +4,9 @@ Run the following command in your project to get the latest version of the plugi `composer require yajra/laravel-datatables-buttons:^3.0` +## Configuration +> This step is optional if you are using Laravel 5.5 + Open the file ```config/app.php``` and then add following service provider. ```php diff --git a/html-installation.md b/html-installation.md index ab5c023..e0d0415 100644 --- a/html-installation.md +++ b/html-installation.md @@ -6,6 +6,9 @@ Run the following command in your project to get the latest version of the plugi `composer require yajra/laravel-datatables-html:^3.0` +## Configuration +> This step is optional if you are using Laravel 5.5 + Open the file ```config/app.php``` and then add following service provider. ```php From 74c511ddbd337a4eea5a7db7e03a94a1ab480778 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 14:49:23 +0800 Subject: [PATCH 080/264] organized button documents --- buttons-config.md => buttons/buttons-config.md | 0 buttons-console.md => buttons/buttons-console.md | 0 buttons-custom.md => buttons/buttons-custom.md | 0 buttons-export.md => buttons/buttons-export.md | 0 buttons-extended.md => buttons/buttons-extended.md | 0 buttons-installation.md => buttons/buttons-installation.md | 0 buttons-starter.md => buttons/buttons-starter.md | 0 buttons-with.md => buttons/buttons-with.md | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename buttons-config.md => buttons/buttons-config.md (100%) rename buttons-console.md => buttons/buttons-console.md (100%) rename buttons-custom.md => buttons/buttons-custom.md (100%) rename buttons-export.md => buttons/buttons-export.md (100%) rename buttons-extended.md => buttons/buttons-extended.md (100%) rename buttons-installation.md => buttons/buttons-installation.md (100%) rename buttons-starter.md => buttons/buttons-starter.md (100%) rename buttons-with.md => buttons/buttons-with.md (100%) diff --git a/buttons-config.md b/buttons/buttons-config.md similarity index 100% rename from buttons-config.md rename to buttons/buttons-config.md diff --git a/buttons-console.md b/buttons/buttons-console.md similarity index 100% rename from buttons-console.md rename to buttons/buttons-console.md diff --git a/buttons-custom.md b/buttons/buttons-custom.md similarity index 100% rename from buttons-custom.md rename to buttons/buttons-custom.md diff --git a/buttons-export.md b/buttons/buttons-export.md similarity index 100% rename from buttons-export.md rename to buttons/buttons-export.md diff --git a/buttons-extended.md b/buttons/buttons-extended.md similarity index 100% rename from buttons-extended.md rename to buttons/buttons-extended.md diff --git a/buttons-installation.md b/buttons/buttons-installation.md similarity index 100% rename from buttons-installation.md rename to buttons/buttons-installation.md diff --git a/buttons-starter.md b/buttons/buttons-starter.md similarity index 100% rename from buttons-starter.md rename to buttons/buttons-starter.md diff --git a/buttons-with.md b/buttons/buttons-with.md similarity index 100% rename from buttons-with.md rename to buttons/buttons-with.md From ab1e1908ef4b8b10476eab56e4219bcdef76fab2 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:03:34 +0800 Subject: [PATCH 081/264] organized html-builder docs and files --- html-builder-action.md => html-builder/html-builder-action.md | 0 html-builder-ajax.md => html-builder/html-builder-ajax.md | 0 .../html-builder-callbacks.md | 0 html-builder-checkbox.md => html-builder/html-builder-checkbox.md | 0 html-builder-column.md => html-builder/html-builder-column.md | 0 html-builder-config.md => html-builder/html-builder-config.md | 0 html-builder-index.md => html-builder/html-builder-index.md | 0 html-builder-macro.md => html-builder/html-builder-macro.md | 0 .../html-builder-minified-ajax.md | 0 .../html-builder-parameters.md | 0 html-builder-table.md => html-builder/html-builder-table.md | 0 html-builder.md => html-builder/html-builder.md | 0 12 files changed, 0 insertions(+), 0 deletions(-) rename html-builder-action.md => html-builder/html-builder-action.md (100%) rename html-builder-ajax.md => html-builder/html-builder-ajax.md (100%) rename html-builder-callbacks.md => html-builder/html-builder-callbacks.md (100%) rename html-builder-checkbox.md => html-builder/html-builder-checkbox.md (100%) rename html-builder-column.md => html-builder/html-builder-column.md (100%) rename html-builder-config.md => html-builder/html-builder-config.md (100%) rename html-builder-index.md => html-builder/html-builder-index.md (100%) rename html-builder-macro.md => html-builder/html-builder-macro.md (100%) rename html-builder-minified-ajax.md => html-builder/html-builder-minified-ajax.md (100%) rename html-builder-parameters.md => html-builder/html-builder-parameters.md (100%) rename html-builder-table.md => html-builder/html-builder-table.md (100%) rename html-builder.md => html-builder/html-builder.md (100%) diff --git a/html-builder-action.md b/html-builder/html-builder-action.md similarity index 100% rename from html-builder-action.md rename to html-builder/html-builder-action.md diff --git a/html-builder-ajax.md b/html-builder/html-builder-ajax.md similarity index 100% rename from html-builder-ajax.md rename to html-builder/html-builder-ajax.md diff --git a/html-builder-callbacks.md b/html-builder/html-builder-callbacks.md similarity index 100% rename from html-builder-callbacks.md rename to html-builder/html-builder-callbacks.md diff --git a/html-builder-checkbox.md b/html-builder/html-builder-checkbox.md similarity index 100% rename from html-builder-checkbox.md rename to html-builder/html-builder-checkbox.md diff --git a/html-builder-column.md b/html-builder/html-builder-column.md similarity index 100% rename from html-builder-column.md rename to html-builder/html-builder-column.md diff --git a/html-builder-config.md b/html-builder/html-builder-config.md similarity index 100% rename from html-builder-config.md rename to html-builder/html-builder-config.md diff --git a/html-builder-index.md b/html-builder/html-builder-index.md similarity index 100% rename from html-builder-index.md rename to html-builder/html-builder-index.md diff --git a/html-builder-macro.md b/html-builder/html-builder-macro.md similarity index 100% rename from html-builder-macro.md rename to html-builder/html-builder-macro.md diff --git a/html-builder-minified-ajax.md b/html-builder/html-builder-minified-ajax.md similarity index 100% rename from html-builder-minified-ajax.md rename to html-builder/html-builder-minified-ajax.md diff --git a/html-builder-parameters.md b/html-builder/html-builder-parameters.md similarity index 100% rename from html-builder-parameters.md rename to html-builder/html-builder-parameters.md diff --git a/html-builder-table.md b/html-builder/html-builder-table.md similarity index 100% rename from html-builder-table.md rename to html-builder/html-builder-table.md diff --git a/html-builder.md b/html-builder/html-builder.md similarity index 100% rename from html-builder.md rename to html-builder/html-builder.md From d5bc0d0fd47962ab53bdea9b0d54e4289ce9f756 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:14:18 +0800 Subject: [PATCH 082/264] updated links and directories for consistency --- buttons/{buttons-config.md => config.md} | 0 buttons/{buttons-console.md => console.md} | 0 buttons/{buttons-custom.md => custom.md} | 0 buttons/{buttons-export.md => export.md} | 0 buttons/{buttons-extended.md => extended.md} | 0 .../{buttons-installation.md => installation.md} | 0 buttons/{buttons-starter.md => starter.md} | 0 buttons/{buttons-with.md => with.md} | 0 documentation.md | 16 ++++++++-------- html-builder-column.md | 4 ++-- 10 files changed, 10 insertions(+), 10 deletions(-) rename buttons/{buttons-config.md => config.md} (100%) rename buttons/{buttons-console.md => console.md} (100%) rename buttons/{buttons-custom.md => custom.md} (100%) rename buttons/{buttons-export.md => export.md} (100%) rename buttons/{buttons-extended.md => extended.md} (100%) rename buttons/{buttons-installation.md => installation.md} (100%) rename buttons/{buttons-starter.md => starter.md} (100%) rename buttons/{buttons-with.md => with.md} (100%) diff --git a/buttons/buttons-config.md b/buttons/config.md similarity index 100% rename from buttons/buttons-config.md rename to buttons/config.md diff --git a/buttons/buttons-console.md b/buttons/console.md similarity index 100% rename from buttons/buttons-console.md rename to buttons/console.md diff --git a/buttons/buttons-custom.md b/buttons/custom.md similarity index 100% rename from buttons/buttons-custom.md rename to buttons/custom.md diff --git a/buttons/buttons-export.md b/buttons/export.md similarity index 100% rename from buttons/buttons-export.md rename to buttons/export.md diff --git a/buttons/buttons-extended.md b/buttons/extended.md similarity index 100% rename from buttons/buttons-extended.md rename to buttons/extended.md diff --git a/buttons/buttons-installation.md b/buttons/installation.md similarity index 100% rename from buttons/buttons-installation.md rename to buttons/installation.md diff --git a/buttons/buttons-starter.md b/buttons/starter.md similarity index 100% rename from buttons/buttons-starter.md rename to buttons/starter.md diff --git a/buttons/buttons-with.md b/buttons/with.md similarity index 100% rename from buttons/buttons-with.md rename to buttons/with.md diff --git a/documentation.md b/documentation.md index 0ab8454..c29255c 100644 --- a/documentation.md +++ b/documentation.md @@ -78,13 +78,13 @@ - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons - - [Installation](/docs/{{package}}/{{version}}/buttons-installation) - - [Configuration](/docs/{{package}}/{{version}}/buttons-config) - - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) - - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) - - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) - - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) + - [Installation](/docs/{{package}}/{{version}}/buttons/installation) + - [Configuration](/docs/{{package}}/{{version}}/buttons/config) + - [Quick Starter](/docs/{{package}}/{{version}}/buttons/starter) + - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons/export) + - [Custom Actions](/docs/{{package}}/{{version}}/buttons/custom) + - [Sending Parameters](/docs/{{package}}/{{version}}/buttons/with) + - [Extended DataTable](/docs/{{package}}/{{version}}/buttons/extended) + - [Artisan Console](/docs/{{package}}/{{version}}/buttons/console) - [Github](https://github.com/yajra/laravel-datatables-buttons) diff --git a/html-builder-column.md b/html-builder-column.md index ab21bf4..7965ebd 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -55,9 +55,9 @@ Footer attribute will be as your `tables` column's `footer` content ` Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons/installation) ### Printable (Optional) Printable attribute will flag the column to be included when `printing` the table. Default value is `true`. -> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons/installation) From f4d9853235f20274639a24fd26b101ad5a16022f Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:24:55 +0800 Subject: [PATCH 083/264] organized files and links for html-builder --- documentation.md | 26 +++++++++---------- .../{html-builder-action.md => action.md} | 0 .../{html-builder-ajax.md => ajax.md} | 0 ...html-builder-macro.md => builder-macro.md} | 0 html-builder/{html-builder.md => builder.md} | 0 ...html-builder-callbacks.md => callbacks.md} | 0 .../{html-builder-checkbox.md => checkbox.md} | 0 .../{html-builder-column.md => column.md} | 0 .../{html-builder-config.md => config.md} | 0 .../{html-builder-index.md => index.md} | 0 ...lder-minified-ajax.md => minified-ajax.md} | 0 ...ml-builder-parameters.md => parameters.md} | 0 .../{html-builder-table.md => table.md} | 0 13 files changed, 13 insertions(+), 13 deletions(-) rename html-builder/{html-builder-action.md => action.md} (100%) rename html-builder/{html-builder-ajax.md => ajax.md} (100%) rename html-builder/{html-builder-macro.md => builder-macro.md} (100%) rename html-builder/{html-builder.md => builder.md} (100%) rename html-builder/{html-builder-callbacks.md => callbacks.md} (100%) rename html-builder/{html-builder-checkbox.md => checkbox.md} (100%) rename html-builder/{html-builder-column.md => column.md} (100%) rename html-builder/{html-builder-config.md => config.md} (100%) rename html-builder/{html-builder-index.md => index.md} (100%) rename html-builder/{html-builder-minified-ajax.md => minified-ajax.md} (100%) rename html-builder/{html-builder-parameters.md => parameters.md} (100%) rename html-builder/{html-builder-table.md => table.md} (100%) diff --git a/documentation.md b/documentation.md index 0ab8454..3f0d9bb 100644 --- a/documentation.md +++ b/documentation.md @@ -62,19 +62,19 @@ ### PLUGINS - HTML Builder - - [Installation](/docs/{{package}}/{{version}}/html-installation) - - [Builder](/docs/{{package}}/{{version}}/html-builder) - - [Table](/docs/{{package}}/{{version}}/html-builder-table) - - [Config](/docs/{{package}}/{{version}}/html-builder-config) - - [Columns](/docs/{{package}}/{{version}}/html-builder-column) - - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) - - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) - - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) - - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) - - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) + - [Installation](/docs/{{package}}/{{version}}/html-builder/installation) + - [Builder](/docs/{{package}}/{{version}}/html-builder/builder) + - [Table](/docs/{{package}}/{{version}}/html-builder/builder-table) + - [Config](/docs/{{package}}/{{version}}/html-builder/builder-config) + - [Columns](/docs/{{package}}/{{version}}/html-builder/builder-column) + - [Macro](/docs/{{package}}/{{version}}/html-builder/builder-macro) + - [Ajax](/docs/{{package}}/{{version}}/html-builder/builder-ajax) + - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder/builder-minified-ajax) + - [Parameters](/docs/{{package}}/{{version}}/html-builder/builder-parameters) + - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder/builder-callbacks) + - [Add Action](/docs/{{package}}/{{version}}/html-builder/builder-action) + - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder/builder-checkbox) + - [Add Index](/docs/{{package}}/{{version}}/html-builder/builder-index) - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons diff --git a/html-builder/html-builder-action.md b/html-builder/action.md similarity index 100% rename from html-builder/html-builder-action.md rename to html-builder/action.md diff --git a/html-builder/html-builder-ajax.md b/html-builder/ajax.md similarity index 100% rename from html-builder/html-builder-ajax.md rename to html-builder/ajax.md diff --git a/html-builder/html-builder-macro.md b/html-builder/builder-macro.md similarity index 100% rename from html-builder/html-builder-macro.md rename to html-builder/builder-macro.md diff --git a/html-builder/html-builder.md b/html-builder/builder.md similarity index 100% rename from html-builder/html-builder.md rename to html-builder/builder.md diff --git a/html-builder/html-builder-callbacks.md b/html-builder/callbacks.md similarity index 100% rename from html-builder/html-builder-callbacks.md rename to html-builder/callbacks.md diff --git a/html-builder/html-builder-checkbox.md b/html-builder/checkbox.md similarity index 100% rename from html-builder/html-builder-checkbox.md rename to html-builder/checkbox.md diff --git a/html-builder/html-builder-column.md b/html-builder/column.md similarity index 100% rename from html-builder/html-builder-column.md rename to html-builder/column.md diff --git a/html-builder/html-builder-config.md b/html-builder/config.md similarity index 100% rename from html-builder/html-builder-config.md rename to html-builder/config.md diff --git a/html-builder/html-builder-index.md b/html-builder/index.md similarity index 100% rename from html-builder/html-builder-index.md rename to html-builder/index.md diff --git a/html-builder/html-builder-minified-ajax.md b/html-builder/minified-ajax.md similarity index 100% rename from html-builder/html-builder-minified-ajax.md rename to html-builder/minified-ajax.md diff --git a/html-builder/html-builder-parameters.md b/html-builder/parameters.md similarity index 100% rename from html-builder/html-builder-parameters.md rename to html-builder/parameters.md diff --git a/html-builder/html-builder-table.md b/html-builder/table.md similarity index 100% rename from html-builder/html-builder-table.md rename to html-builder/table.md From c012f2e3e7254606339898e693f9ce876aa07696 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:45:56 +0800 Subject: [PATCH 084/264] renamed html-builder folders to html --- documentation.md | 26 ++++++++++---------- {html-builder => html}/action.md | 0 {html-builder => html}/ajax.md | 0 {html-builder => html}/builder-macro.md | 0 {html-builder => html}/builder.md | 0 {html-builder => html}/callbacks.md | 0 {html-builder => html}/checkbox.md | 0 {html-builder => html}/column.md | 0 {html-builder => html}/config.md | 0 {html-builder => html}/index.md | 0 html-installation.md => html/installation.md | 0 {html-builder => html}/minified-ajax.md | 0 {html-builder => html}/parameters.md | 0 {html-builder => html}/table.md | 0 14 files changed, 13 insertions(+), 13 deletions(-) rename {html-builder => html}/action.md (100%) rename {html-builder => html}/ajax.md (100%) rename {html-builder => html}/builder-macro.md (100%) rename {html-builder => html}/builder.md (100%) rename {html-builder => html}/callbacks.md (100%) rename {html-builder => html}/checkbox.md (100%) rename {html-builder => html}/column.md (100%) rename {html-builder => html}/config.md (100%) rename {html-builder => html}/index.md (100%) rename html-installation.md => html/installation.md (100%) rename {html-builder => html}/minified-ajax.md (100%) rename {html-builder => html}/parameters.md (100%) rename {html-builder => html}/table.md (100%) diff --git a/documentation.md b/documentation.md index 45ff40a..4275c68 100644 --- a/documentation.md +++ b/documentation.md @@ -62,19 +62,19 @@ ### PLUGINS - HTML Builder - - [Installation](/docs/{{package}}/{{version}}/html-builder/installation) - - [Builder](/docs/{{package}}/{{version}}/html-builder/builder) - - [Table](/docs/{{package}}/{{version}}/html-builder/builder-table) - - [Config](/docs/{{package}}/{{version}}/html-builder/builder-config) - - [Columns](/docs/{{package}}/{{version}}/html-builder/builder-column) - - [Macro](/docs/{{package}}/{{version}}/html-builder/builder-macro) - - [Ajax](/docs/{{package}}/{{version}}/html-builder/builder-ajax) - - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder/builder-minified-ajax) - - [Parameters](/docs/{{package}}/{{version}}/html-builder/builder-parameters) - - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder/builder-callbacks) - - [Add Action](/docs/{{package}}/{{version}}/html-builder/builder-action) - - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder/builder-checkbox) - - [Add Index](/docs/{{package}}/{{version}}/html-builder/builder-index) + - [Installation](/docs/{{package}}/{{version}}/html/installation) + - [Builder](/docs/{{package}}/{{version}}/html/builder) + - [Table](/docs/{{package}}/{{version}}/html/table) + - [Config](/docs/{{package}}/{{version}}/html/config) + - [Columns](/docs/{{package}}/{{version}}/html/column) + - [Macro](/docs/{{package}}/{{version}}/html/macro) + - [Ajax](/docs/{{package}}/{{version}}/html/ajax) + - [Minified Ajax](/docs/{{package}}/{{version}}/html/minified-ajax) + - [Parameters](/docs/{{package}}/{{version}}/html/parameters) + - [Events/Callbacks](/docs/{{package}}/{{version}}/html/callbacks) + - [Add Action](/docs/{{package}}/{{version}}/html/action) + - [Add Checkbox](/docs/{{package}}/{{version}}/html/checkbox) + - [Add Index](/docs/{{package}}/{{version}}/html/index) - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons diff --git a/html-builder/action.md b/html/action.md similarity index 100% rename from html-builder/action.md rename to html/action.md diff --git a/html-builder/ajax.md b/html/ajax.md similarity index 100% rename from html-builder/ajax.md rename to html/ajax.md diff --git a/html-builder/builder-macro.md b/html/builder-macro.md similarity index 100% rename from html-builder/builder-macro.md rename to html/builder-macro.md diff --git a/html-builder/builder.md b/html/builder.md similarity index 100% rename from html-builder/builder.md rename to html/builder.md diff --git a/html-builder/callbacks.md b/html/callbacks.md similarity index 100% rename from html-builder/callbacks.md rename to html/callbacks.md diff --git a/html-builder/checkbox.md b/html/checkbox.md similarity index 100% rename from html-builder/checkbox.md rename to html/checkbox.md diff --git a/html-builder/column.md b/html/column.md similarity index 100% rename from html-builder/column.md rename to html/column.md diff --git a/html-builder/config.md b/html/config.md similarity index 100% rename from html-builder/config.md rename to html/config.md diff --git a/html-builder/index.md b/html/index.md similarity index 100% rename from html-builder/index.md rename to html/index.md diff --git a/html-installation.md b/html/installation.md similarity index 100% rename from html-installation.md rename to html/installation.md diff --git a/html-builder/minified-ajax.md b/html/minified-ajax.md similarity index 100% rename from html-builder/minified-ajax.md rename to html/minified-ajax.md diff --git a/html-builder/parameters.md b/html/parameters.md similarity index 100% rename from html-builder/parameters.md rename to html/parameters.md diff --git a/html-builder/table.md b/html/table.md similarity index 100% rename from html-builder/table.md rename to html/table.md From 32a1c4e2397841e6f9dfc037644b36ecdb9cbf01 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:49:01 +0800 Subject: [PATCH 085/264] fix builder-macro filename --- html/{builder-macro.md => macro.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename html/{builder-macro.md => macro.md} (100%) diff --git a/html/builder-macro.md b/html/macro.md similarity index 100% rename from html/builder-macro.md rename to html/macro.md From f3f55252b948a60a6c3585b20e170472e5c43a46 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 15:54:38 +0800 Subject: [PATCH 086/264] organized response folder --- documentation.md | 10 +++++----- response-array.md => response/array.md | 0 .../fractal-serializer.md | 0 response-fractal.md => response/fractal.md | 0 response-object.md => response/object.md | 0 response-with.md => response/with.md | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename response-array.md => response/array.md (100%) rename response-fractal-serializer.md => response/fractal-serializer.md (100%) rename response-fractal.md => response/fractal.md (100%) rename response-object.md => response/object.md (100%) rename response-with.md => response/with.md (100%) diff --git a/documentation.md b/documentation.md index 4275c68..9755428 100644 --- a/documentation.md +++ b/documentation.md @@ -21,11 +21,11 @@ - [Query Builder](/docs/{{package}}/{{version}}/engine-query) - [Collection](/docs/{{package}}/{{version}}/engine-collection) - Response - - [Array Response](/docs/{{package}}/{{version}}/response-array) - - [Object Response](/docs/{{package}}/{{version}}/response-object) - - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) + - [Array Response](/docs/{{package}}/{{version}}/response/array) + - [Object Response](/docs/{{package}}/{{version}}/response/object) + - [Fractal Transformer](/docs/{{package}}/{{version}}/response/fractal) + - [Fractal Serializer](/docs/{{package}}/{{version}}/response/fractal-serializer) + - [Additional Data Response](/docs/{{package}}/{{version}}/response/with) - Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) - [Edit Column](/docs/{{package}}/{{version}}/edit-column) diff --git a/response-array.md b/response/array.md similarity index 100% rename from response-array.md rename to response/array.md diff --git a/response-fractal-serializer.md b/response/fractal-serializer.md similarity index 100% rename from response-fractal-serializer.md rename to response/fractal-serializer.md diff --git a/response-fractal.md b/response/fractal.md similarity index 100% rename from response-fractal.md rename to response/fractal.md diff --git a/response-object.md b/response/object.md similarity index 100% rename from response-object.md rename to response/object.md diff --git a/response-with.md b/response/with.md similarity index 100% rename from response-with.md rename to response/with.md From 029c0153aadac0f619de430ed79fa4ac9f7031e8 Mon Sep 17 00:00:00 2001 From: iman Date: Sat, 28 Oct 2017 16:03:50 +0800 Subject: [PATCH 087/264] organized engine docs --- documentation.md | 6 +++--- engine-collection.md => engine/collection.md | 0 engine-eloquent.md => engine/eloquent.md | 0 engine-query.md => engine/query.md | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename engine-collection.md => engine/collection.md (100%) rename engine-eloquent.md => engine/eloquent.md (100%) rename engine-query.md => engine/query.md (100%) diff --git a/documentation.md b/documentation.md index 9755428..bc24693 100644 --- a/documentation.md +++ b/documentation.md @@ -17,9 +17,9 @@ - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - [Error Handler](/docs/{{package}}/{{version}}/error-handler) - DataTables Classes - - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) - - [Query Builder](/docs/{{package}}/{{version}}/engine-query) - - [Collection](/docs/{{package}}/{{version}}/engine-collection) + - [Eloquent](/docs/{{package}}/{{version}}/engine/eloquent) + - [Query Builder](/docs/{{package}}/{{version}}/engine/query) + - [Collection](/docs/{{package}}/{{version}}/engine/collection) - Response - [Array Response](/docs/{{package}}/{{version}}/response/array) - [Object Response](/docs/{{package}}/{{version}}/response/object) diff --git a/engine-collection.md b/engine/collection.md similarity index 100% rename from engine-collection.md rename to engine/collection.md diff --git a/engine-eloquent.md b/engine/eloquent.md similarity index 100% rename from engine-eloquent.md rename to engine/eloquent.md diff --git a/engine-query.md b/engine/query.md similarity index 100% rename from engine-query.md rename to engine/query.md From 1d14d47d08af975d28b309480e0212a45ef55142 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:07:00 +0800 Subject: [PATCH 088/264] Add Post method Export Instructions --- buttons/export.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/buttons/export.md b/buttons/export.md index eef8400..6498745 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -105,6 +105,33 @@ class UsersDataTable extends DataTable ... ``` + +## Export as Excel, CSV, and PDF using POST method + +To enable exporting to excel, csv, and pdf using POST method set the following on the buttons array. +This is recommended if you have a long query and if you are using IE browsers. + +```php +namespace App\DataTables; + +use App\User; +use Yajra\DataTables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + //...some default stubs deleted for simplicity. + + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->parameters([ + 'buttons' => ['postExcel', 'postCsv', 'postPdf'], + ]); + } +... +``` + ## Printable Version From 95ede0bb0194f6051df57983b93a0604a1d7ad2c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:27:45 +0800 Subject: [PATCH 089/264] change to post-export, add routes instruction --- buttons/export.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buttons/export.md b/buttons/export.md index 6498745..176f3dd 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -105,7 +105,7 @@ class UsersDataTable extends DataTable ... ``` - + ## Export as Excel, CSV, and PDF using POST method To enable exporting to excel, csv, and pdf using POST method set the following on the buttons array. @@ -132,6 +132,12 @@ class UsersDataTable extends DataTable ... ``` +And also add this code to your routes.php file. +```php + $router->post('sample/export', SampleController::class . '@index'); +... +``` + ## Printable Version From 6523b59f1e6e2547d0a406e94fd990bc9630172c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Fri, 3 Nov 2017 09:32:50 +0800 Subject: [PATCH 090/264] change routes instruction --- buttons/export.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buttons/export.md b/buttons/export.md index 176f3dd..febf73e 100644 --- a/buttons/export.md +++ b/buttons/export.md @@ -134,7 +134,8 @@ class UsersDataTable extends DataTable And also add this code to your routes.php file. ```php - $router->post('sample/export', SampleController::class . '@index'); + Route::resource('sample', 'SampleController@index'); + Route::post('sample/export', 'SampleController@index'); ... ``` From 4464b36490600ce13238e7217337383a23ef2136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Thu, 16 Nov 2017 16:04:53 +0100 Subject: [PATCH 091/264] wrong function call this function should be called https://github.com/yajra/laravel-datatables/blob/8.0/src/DataTables.php#L124 for instanciating with a collection --- engine/collection.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/collection.md b/engine/collection.md index 566805a..663005c 100644 --- a/engine/collection.md +++ b/engine/collection.md @@ -33,7 +33,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return DataTables::queryBuilder($collection)->toJson(); + return DataTables::collection($collection)->toJson(); }); ``` @@ -50,7 +50,7 @@ Route::get('user-data', function(DataTables $datatables) { ['id' => 3, 'name' => 'James'], ]); - return $datatables->queryBuilder($collection)->toJson(); + return $datatables->collection($collection)->toJson(); }); ``` @@ -65,7 +65,7 @@ Route::get('user-data', function() { ['id' => 3, 'name' => 'James'], ]); - return app('datatables')->queryBuilder($collection)->toJson(); + return app('datatables')->collection($collection)->toJson(); }); ``` From 84bda72c1fcdd1be7ef4e52f1b6c0091ed8ae632 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 08:32:41 +0800 Subject: [PATCH 092/264] Use camelCase variable name. --- engine/collection.md | 4 ++-- engine/eloquent.md | 4 ++-- engine/query.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/collection.md b/engine/collection.md index 663005c..3b8bed0 100644 --- a/engine/collection.md +++ b/engine/collection.md @@ -43,14 +43,14 @@ Route::get('user-data', function() { ```php use Yajra\DataTables\DataTables; -Route::get('user-data', function(DataTables $datatables) { +Route::get('user-data', function(DataTables $dataTables) { $collection = collect([ ['id' => 1, 'name' => 'John'], ['id' => 2, 'name' => 'Jane'], ['id' => 3, 'name' => 'James'], ]); - return $datatables->collection($collection)->toJson(); + return $dataTables->collection($collection)->toJson(); }); ``` diff --git a/engine/eloquent.md b/engine/eloquent.md index 5e20a17..e2874c9 100644 --- a/engine/eloquent.md +++ b/engine/eloquent.md @@ -35,10 +35,10 @@ Route::get('user-data', function() { ```php use Yajra\DataTables\DataTables; -Route::get('user-data', function(DataTables $datatables) { +Route::get('user-data', function(DataTables $dataTables) { $model = App\User::query(); - return $datatables->eloquent($model)->toJson(); + return $dataTables->eloquent($model)->toJson(); }); ``` diff --git a/engine/query.md b/engine/query.md index 09663f1..4d2c09d 100644 --- a/engine/query.md +++ b/engine/query.md @@ -38,10 +38,10 @@ Route::get('user-data', function() { use DB; use Yajra\DataTables\DataTables; -Route::get('user-data', function(DataTables $datatables) { +Route::get('user-data', function(DataTables $dataTables) { $query = DB::table('users'); - return $datatables->queryBuilder($query)->toJson(); + return $dataTables->queryBuilder($query)->toJson(); }); ``` From c7e256edace0b0df47b386ab856f8839ab88ee57 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 12:55:35 +0800 Subject: [PATCH 093/264] Revert "Organized engine docs." --- documentation.md | 6 +++--- engine/collection.md => engine-collection.md | 0 engine/eloquent.md => engine-eloquent.md | 0 engine/query.md => engine-query.md | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename engine/collection.md => engine-collection.md (100%) rename engine/eloquent.md => engine-eloquent.md (100%) rename engine/query.md => engine-query.md (100%) diff --git a/documentation.md b/documentation.md index bc24693..9755428 100644 --- a/documentation.md +++ b/documentation.md @@ -17,9 +17,9 @@ - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - [Error Handler](/docs/{{package}}/{{version}}/error-handler) - DataTables Classes - - [Eloquent](/docs/{{package}}/{{version}}/engine/eloquent) - - [Query Builder](/docs/{{package}}/{{version}}/engine/query) - - [Collection](/docs/{{package}}/{{version}}/engine/collection) + - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) + - [Query Builder](/docs/{{package}}/{{version}}/engine-query) + - [Collection](/docs/{{package}}/{{version}}/engine-collection) - Response - [Array Response](/docs/{{package}}/{{version}}/response/array) - [Object Response](/docs/{{package}}/{{version}}/response/object) diff --git a/engine/collection.md b/engine-collection.md similarity index 100% rename from engine/collection.md rename to engine-collection.md diff --git a/engine/eloquent.md b/engine-eloquent.md similarity index 100% rename from engine/eloquent.md rename to engine-eloquent.md diff --git a/engine/query.md b/engine-query.md similarity index 100% rename from engine/query.md rename to engine-query.md From 3f16fd42971e99faaedac3669410140e39144c25 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 12:55:43 +0800 Subject: [PATCH 094/264] Revert "Organized response folder." --- documentation.md | 10 +++++----- response/array.md => response-array.md | 0 ...tal-serializer.md => response-fractal-serializer.md | 0 response/fractal.md => response-fractal.md | 0 response/object.md => response-object.md | 0 response/with.md => response-with.md | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename response/array.md => response-array.md (100%) rename response/fractal-serializer.md => response-fractal-serializer.md (100%) rename response/fractal.md => response-fractal.md (100%) rename response/object.md => response-object.md (100%) rename response/with.md => response-with.md (100%) diff --git a/documentation.md b/documentation.md index bc24693..eea9329 100644 --- a/documentation.md +++ b/documentation.md @@ -21,11 +21,11 @@ - [Query Builder](/docs/{{package}}/{{version}}/engine/query) - [Collection](/docs/{{package}}/{{version}}/engine/collection) - Response - - [Array Response](/docs/{{package}}/{{version}}/response/array) - - [Object Response](/docs/{{package}}/{{version}}/response/object) - - [Fractal Transformer](/docs/{{package}}/{{version}}/response/fractal) - - [Fractal Serializer](/docs/{{package}}/{{version}}/response/fractal-serializer) - - [Additional Data Response](/docs/{{package}}/{{version}}/response/with) + - [Array Response](/docs/{{package}}/{{version}}/response-array) + - [Object Response](/docs/{{package}}/{{version}}/response-object) + - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) + - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) + - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) - Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) - [Edit Column](/docs/{{package}}/{{version}}/edit-column) diff --git a/response/array.md b/response-array.md similarity index 100% rename from response/array.md rename to response-array.md diff --git a/response/fractal-serializer.md b/response-fractal-serializer.md similarity index 100% rename from response/fractal-serializer.md rename to response-fractal-serializer.md diff --git a/response/fractal.md b/response-fractal.md similarity index 100% rename from response/fractal.md rename to response-fractal.md diff --git a/response/object.md b/response-object.md similarity index 100% rename from response/object.md rename to response-object.md diff --git a/response/with.md b/response-with.md similarity index 100% rename from response/with.md rename to response-with.md From c0fda1ff6f551212ae225e9439495aef301e4219 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 12:55:56 +0800 Subject: [PATCH 095/264] Revert "Organized html builder plugin docs." --- documentation.md | 26 +++++++++---------- html/action.md => html-builder-action.md | 0 html/ajax.md => html-builder-ajax.md | 0 .../callbacks.md => html-builder-callbacks.md | 0 html/checkbox.md => html-builder-checkbox.md | 0 html/column.md => html-builder-column.md | 0 html/config.md => html-builder-config.md | 0 html/index.md => html-builder-index.md | 0 html/macro.md => html-builder-macro.md | 0 ...d-ajax.md => html-builder-minified-ajax.md | 0 ...arameters.md => html-builder-parameters.md | 0 html/table.md => html-builder-table.md | 0 html/builder.md => html-builder.md | 0 html/installation.md => html-installation.md | 0 14 files changed, 13 insertions(+), 13 deletions(-) rename html/action.md => html-builder-action.md (100%) rename html/ajax.md => html-builder-ajax.md (100%) rename html/callbacks.md => html-builder-callbacks.md (100%) rename html/checkbox.md => html-builder-checkbox.md (100%) rename html/column.md => html-builder-column.md (100%) rename html/config.md => html-builder-config.md (100%) rename html/index.md => html-builder-index.md (100%) rename html/macro.md => html-builder-macro.md (100%) rename html/minified-ajax.md => html-builder-minified-ajax.md (100%) rename html/parameters.md => html-builder-parameters.md (100%) rename html/table.md => html-builder-table.md (100%) rename html/builder.md => html-builder.md (100%) rename html/installation.md => html-installation.md (100%) diff --git a/documentation.md b/documentation.md index bc24693..99a7311 100644 --- a/documentation.md +++ b/documentation.md @@ -62,19 +62,19 @@ ### PLUGINS - HTML Builder - - [Installation](/docs/{{package}}/{{version}}/html/installation) - - [Builder](/docs/{{package}}/{{version}}/html/builder) - - [Table](/docs/{{package}}/{{version}}/html/table) - - [Config](/docs/{{package}}/{{version}}/html/config) - - [Columns](/docs/{{package}}/{{version}}/html/column) - - [Macro](/docs/{{package}}/{{version}}/html/macro) - - [Ajax](/docs/{{package}}/{{version}}/html/ajax) - - [Minified Ajax](/docs/{{package}}/{{version}}/html/minified-ajax) - - [Parameters](/docs/{{package}}/{{version}}/html/parameters) - - [Events/Callbacks](/docs/{{package}}/{{version}}/html/callbacks) - - [Add Action](/docs/{{package}}/{{version}}/html/action) - - [Add Checkbox](/docs/{{package}}/{{version}}/html/checkbox) - - [Add Index](/docs/{{package}}/{{version}}/html/index) + - [Installation](/docs/{{package}}/{{version}}/html-installation) + - [Builder](/docs/{{package}}/{{version}}/html-builder) + - [Table](/docs/{{package}}/{{version}}/html-builder-table) + - [Config](/docs/{{package}}/{{version}}/html-builder-config) + - [Columns](/docs/{{package}}/{{version}}/html-builder-column) + - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) + - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) + - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) + - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) + - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) + - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) + - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) + - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons diff --git a/html/action.md b/html-builder-action.md similarity index 100% rename from html/action.md rename to html-builder-action.md diff --git a/html/ajax.md b/html-builder-ajax.md similarity index 100% rename from html/ajax.md rename to html-builder-ajax.md diff --git a/html/callbacks.md b/html-builder-callbacks.md similarity index 100% rename from html/callbacks.md rename to html-builder-callbacks.md diff --git a/html/checkbox.md b/html-builder-checkbox.md similarity index 100% rename from html/checkbox.md rename to html-builder-checkbox.md diff --git a/html/column.md b/html-builder-column.md similarity index 100% rename from html/column.md rename to html-builder-column.md diff --git a/html/config.md b/html-builder-config.md similarity index 100% rename from html/config.md rename to html-builder-config.md diff --git a/html/index.md b/html-builder-index.md similarity index 100% rename from html/index.md rename to html-builder-index.md diff --git a/html/macro.md b/html-builder-macro.md similarity index 100% rename from html/macro.md rename to html-builder-macro.md diff --git a/html/minified-ajax.md b/html-builder-minified-ajax.md similarity index 100% rename from html/minified-ajax.md rename to html-builder-minified-ajax.md diff --git a/html/parameters.md b/html-builder-parameters.md similarity index 100% rename from html/parameters.md rename to html-builder-parameters.md diff --git a/html/table.md b/html-builder-table.md similarity index 100% rename from html/table.md rename to html-builder-table.md diff --git a/html/builder.md b/html-builder.md similarity index 100% rename from html/builder.md rename to html-builder.md diff --git a/html/installation.md b/html-installation.md similarity index 100% rename from html/installation.md rename to html-installation.md From 92080824673e03d7fc2922308dcfee33780e73cc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 12:56:07 +0800 Subject: [PATCH 096/264] Revert "Organized button documents" --- buttons/config.md => buttons-config.md | 0 buttons/console.md => buttons-console.md | 0 buttons/custom.md => buttons-custom.md | 0 buttons/export.md => buttons-export.md | 0 buttons/extended.md => buttons-extended.md | 0 .../installation.md => buttons-installation.md | 0 buttons/starter.md => buttons-starter.md | 0 buttons/with.md => buttons-with.md | 0 documentation.md | 16 ++++++++-------- html/column.md | 4 ++-- 10 files changed, 10 insertions(+), 10 deletions(-) rename buttons/config.md => buttons-config.md (100%) rename buttons/console.md => buttons-console.md (100%) rename buttons/custom.md => buttons-custom.md (100%) rename buttons/export.md => buttons-export.md (100%) rename buttons/extended.md => buttons-extended.md (100%) rename buttons/installation.md => buttons-installation.md (100%) rename buttons/starter.md => buttons-starter.md (100%) rename buttons/with.md => buttons-with.md (100%) diff --git a/buttons/config.md b/buttons-config.md similarity index 100% rename from buttons/config.md rename to buttons-config.md diff --git a/buttons/console.md b/buttons-console.md similarity index 100% rename from buttons/console.md rename to buttons-console.md diff --git a/buttons/custom.md b/buttons-custom.md similarity index 100% rename from buttons/custom.md rename to buttons-custom.md diff --git a/buttons/export.md b/buttons-export.md similarity index 100% rename from buttons/export.md rename to buttons-export.md diff --git a/buttons/extended.md b/buttons-extended.md similarity index 100% rename from buttons/extended.md rename to buttons-extended.md diff --git a/buttons/installation.md b/buttons-installation.md similarity index 100% rename from buttons/installation.md rename to buttons-installation.md diff --git a/buttons/starter.md b/buttons-starter.md similarity index 100% rename from buttons/starter.md rename to buttons-starter.md diff --git a/buttons/with.md b/buttons-with.md similarity index 100% rename from buttons/with.md rename to buttons-with.md diff --git a/documentation.md b/documentation.md index bc24693..5933e75 100644 --- a/documentation.md +++ b/documentation.md @@ -78,13 +78,13 @@ - [Github](https://github.com/yajra/laravel-datatables-html) - Buttons - - [Installation](/docs/{{package}}/{{version}}/buttons/installation) - - [Configuration](/docs/{{package}}/{{version}}/buttons/config) - - [Quick Starter](/docs/{{package}}/{{version}}/buttons/starter) - - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons/export) - - [Custom Actions](/docs/{{package}}/{{version}}/buttons/custom) - - [Sending Parameters](/docs/{{package}}/{{version}}/buttons/with) - - [Extended DataTable](/docs/{{package}}/{{version}}/buttons/extended) - - [Artisan Console](/docs/{{package}}/{{version}}/buttons/console) + - [Installation](/docs/{{package}}/{{version}}/buttons-installation) + - [Configuration](/docs/{{package}}/{{version}}/buttons-config) + - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) + - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) + - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) + - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) + - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) + - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) diff --git a/html/column.md b/html/column.md index 7965ebd..ab21bf4 100644 --- a/html/column.md +++ b/html/column.md @@ -55,9 +55,9 @@ Footer attribute will be as your `tables` column's `footer` content ` Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons/installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) ### Printable (Optional) Printable attribute will flag the column to be included when `printing` the table. Default value is `true`. -> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons/installation) +> Exportable attribute should be used with the [Buttons Plugin](/docs/{{package}}/{{version}}/buttons-installation) From 8d9fc369cd714a1eb50cae7893ab5e24537ece8c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 16:14:22 +0800 Subject: [PATCH 097/264] Group docs by section. --- documentation.md | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/documentation.md b/documentation.md index 0ab8454..8ef860c 100644 --- a/documentation.md +++ b/documentation.md @@ -1,56 +1,55 @@ -- Prologue +- ## Prologue - [Release Notes](/docs/{{package}}/{{version}}/releases) - [Upgrade Guide](/docs/{{package}}/{{version}}/upgrade) - [Contribution Guide](/docs/{{package}}/{{version}}/contributing) - [Security Issues](/docs/{{package}}/{{version}}/security) - [API Documentation](http://yajra.github.io/{{package}}/api/{{version}}) -- Setup - - [Installation](/docs/{{package}}/{{version}}/installation) -- Getting Started +- ## Getting Started - [Introduction](/docs/{{package}}/{{version}}/introduction) + - [Installation](/docs/{{package}}/{{version}}/installation) - [Demo Application](https://datatables.yajrabox.com/) -- Tutorials +- ## Tutorials - [Quick Starter](https://datatables.yajrabox.com/starter) - [Service Implementation](https://datatables.yajrabox.com/service) -- Configuration +- ## Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - [Error Handler](/docs/{{package}}/{{version}}/error-handler) -- DataTables Classes +- ## DataTables Classes - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) - [Query Builder](/docs/{{package}}/{{version}}/engine-query) - [Collection](/docs/{{package}}/{{version}}/engine-collection) -- Response +- ## Response - [Array Response](/docs/{{package}}/{{version}}/response-array) - [Object Response](/docs/{{package}}/{{version}}/response-object) - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) -- Column Editing +- ## Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) - [Edit Column](/docs/{{package}}/{{version}}/edit-column) - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) -- Row Editing +- ## Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) - [Row Class](/docs/{{package}}/{{version}}/row-options#row-class) - [Row Data](/docs/{{package}}/{{version}}/row-options#row-data) - [Row Attributes](/docs/{{package}}/{{version}}/row-options#row-attributes) -- Searching +- ## Searching - [Manual Search](/docs/{{package}}/{{version}}/manual-search) - [Filter Column](/docs/{{package}}/{{version}}/filter-column) - [Query Builder Extension](/docs/{{package}}/{{version}}/query-builder) - [Regex Search](/docs/{{package}}/{{version}}/regex) - [Smart Search](/docs/{{package}}/{{version}}/smart-search) - [Relationships](/docs/{{package}}/{{version}}/relationships) -- Sorting/Ordering +- ## Sorting/Ordering - [Manual Order](/docs/{{package}}/{{version}}/manual-order) - [Order Column](/docs/{{package}}/{{version}}/order-column) - [Order Columns](/docs/{{package}}/{{version}}/order-columns) - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) -- Utilities +- ## Utilities - [XSS filtering](/docs/{{package}}/{{version}}/xss) - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) @@ -61,7 +60,7 @@ ### PLUGINS -- HTML Builder +- ## HTML Builder - [Installation](/docs/{{package}}/{{version}}/html-installation) - [Builder](/docs/{{package}}/{{version}}/html-builder) - [Table](/docs/{{package}}/{{version}}/html-builder-table) @@ -77,7 +76,7 @@ - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) - [Github](https://github.com/yajra/laravel-datatables-html) -- Buttons +- ## Buttons - [Installation](/docs/{{package}}/{{version}}/buttons-installation) - [Configuration](/docs/{{package}}/{{version}}/buttons-config) - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) From 181240e290d1464b38af420e8622fc2e8b7c3da7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 17 Nov 2017 16:57:12 +0800 Subject: [PATCH 098/264] Remove deprecated docs. --- documentation.md | 3 --- only-trashed.md | 16 ---------------- query-builder.md | 16 ---------------- with-trashed.md | 16 ---------------- 4 files changed, 51 deletions(-) delete mode 100644 only-trashed.md delete mode 100644 query-builder.md delete mode 100644 with-trashed.md diff --git a/documentation.md b/documentation.md index 8ef860c..792e6c0 100644 --- a/documentation.md +++ b/documentation.md @@ -40,7 +40,6 @@ - ## Searching - [Manual Search](/docs/{{package}}/{{version}}/manual-search) - [Filter Column](/docs/{{package}}/{{version}}/filter-column) - - [Query Builder Extension](/docs/{{package}}/{{version}}/query-builder) - [Regex Search](/docs/{{package}}/{{version}}/regex) - [Smart Search](/docs/{{package}}/{{version}}/smart-search) - [Relationships](/docs/{{package}}/{{version}}/relationships) @@ -54,8 +53,6 @@ - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) - - [With Trashed](/docs/{{package}}/{{version}}/with-trashed) - - [Only Trashed](/docs/{{package}}/{{version}}/only-trashed) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) ### PLUGINS diff --git a/only-trashed.md b/only-trashed.md deleted file mode 100644 index a970d8e..0000000 --- a/only-trashed.md +++ /dev/null @@ -1,16 +0,0 @@ -# Eloquent Model With Only Trashed - -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include only trashed records in the results. -To achieve this, we can use `onlyTrashed` api. - -```php -use DataTables; - -Route::get('user-data', function() { - $model = App\User::onlyTrashed()->query(); - - return DataTables::eloquent($model) - ->onlyTrashed() - ->toJson(); -}); -``` diff --git a/query-builder.md b/query-builder.md deleted file mode 100644 index d6b88da..0000000 --- a/query-builder.md +++ /dev/null @@ -1,16 +0,0 @@ -# Query Builder Extension - -DataTables instance allows you to proxy a database query call. - -```php -use DataTables; - -Route::get('user-data', function() { - $model = App\User::query(); - - $dataTable = DataTables::eloquent($model); - $dataTable->where('company_id', 2); - - return $dataTable->toJson(); -}); -``` diff --git a/with-trashed.md b/with-trashed.md deleted file mode 100644 index 590c819..0000000 --- a/with-trashed.md +++ /dev/null @@ -1,16 +0,0 @@ -# Eloquent Model With Trashed - -When our `Model` uses `SoftDeletes` trait of Laravel, we need to implicitly tell `DataTables` to include trashed records in the results. -To achieve this, we can use `withTrashed` api. - -```php -use DataTables; - -Route::get('user-data', function() { - $model = App\User::query()->withTrashed(); - - return DataTables::eloquent($model) - ->withTrashed() - ->toJson(); -}); -``` From afe1fabb62fcc1075646cebd5222a838f596136e Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Thu, 14 Dec 2017 09:53:52 +0100 Subject: [PATCH 099/264] Fix route Anonymous functions must not have a name. --- buttons-starter.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/buttons-starter.md b/buttons-starter.md index d3da943..2b4a521 100644 --- a/buttons-starter.md +++ b/buttons-starter.md @@ -49,8 +49,7 @@ class UsersDataTable extends DataTable ```php use App\DataTables\UsersDataTable; -Route::get('users', function getUsers(UsersDataTable $dataTable) -{ +Route::get('users', function(UsersDataTable $dataTable) { return $dataTable->render('users.index'); }); ``` From 404a8c40bbd7345fb8fa089e435aa05150bc2769 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:15:17 +0800 Subject: [PATCH 100/264] Add dataTable editor plugin docs. --- documentation.md | 8 ++- editor-command.md | 158 +++++++++++++++++++++++++++++++++++++++++ editor-events.md | 60 ++++++++++++++++ editor-installation.md | 26 +++++++ editor-rules.md | 39 ++++++++++ 5 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 editor-command.md create mode 100644 editor-events.md create mode 100644 editor-installation.md create mode 100644 editor-rules.md diff --git a/documentation.md b/documentation.md index 792e6c0..4a53c16 100644 --- a/documentation.md +++ b/documentation.md @@ -81,6 +81,12 @@ - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - - [Artisan Console](/docs/{{package}}/{{version}}/buttons-console) + - [Buttons Command](/docs/{{package}}/{{version}}/buttons-console) - [Github](https://github.com/yajra/laravel-datatables-buttons) +- ## Editor + - [Installation](/docs/{{package}}/{{version}}/editor-installation) + - [Editor Command](/docs/{{package}}/{{version}}/editor-command) + - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) + - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) + - [Github](https://github.com/yajra/laravel-datatables-editor) \ No newline at end of file diff --git a/editor-command.md b/editor-command.md new file mode 100644 index 0000000..b8d336f --- /dev/null +++ b/editor-command.md @@ -0,0 +1,158 @@ +# DataTables Editor Command + +## Introduction + +Artisan is the command-line interface included with Laravel. +It provides a number of helpful commands that can assist you while you build your application. +To view a list of all available Artisan commands, you may use the list command: + +```bash +php artisan list +``` + +## Editor Command + +```bash +php artisan datatables:editor {name} +``` + +## Editor Command Options + +`--model` : The name given will be used as the model is singular form. +`--model-namespace` : The namespace of the model to be used. + +## Creating a DataTables Editor class + +In this example, we will create a DataTable Editor class. + +```bash +php artisan datatables:editor Posts +``` + +This will create an `PostsDataTableEditor` class on `app\DataTables` directory. + +```php +namespace App\DataTables; + +use Illuminate\Database\Eloquent\Model; +use Illuminate\Validation\Rule; +use Yajra\DataTables\DataTablesEditor; +use App\User; + +class PostsDataTableEditor extends DataTablesEditor +{ + protected $model = User::class; + + /** + * Get create action validation rules. + * + * @return array + */ + public function createRules() + { + return [ + 'email' => 'required|email', + 'name' => 'required', + ]; + } + + /** + * Get edit action validation rules. + * + * @param Model $model + * @return array + */ + public function editRules(Model $model) + { + return [ + 'email' => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()), + 'name' => 'sometimes|required', + ]; + } + + /** + * Get remove action validation rules. + * + * @param Model $model + * @return array + */ + public function removeRules(Model $model) + { + return []; + } +} +``` + +### Model Option + +In this example, we will pass a `--model` option to set the model to be used by our DataTable. + +```bash +php artisan datatables:editor Posts --model +``` + +This will generate a `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. +The exported filename will also be set to `posts_(timestamp)`. + +```php +namespace App\DataTables; + +use Illuminate\Database\Eloquent\Model; +use Illuminate\Validation\Rule; +use Yajra\DataTables\DataTablesEditor; +use App\Post; + +class PostsDataTableEditor extends DataTablesEditor +{ + protected $model = Post::class; + + /** + * Get create action validation rules. + * + * @return array + */ + public function createRules() + { + return [ + 'email' => 'required|email', + 'name' => 'required', + ]; + } + + /** + * Get edit action validation rules. + * + * @param Model $model + * @return array + */ + public function editRules(Model $model) + { + return [ + 'email' => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()), + 'name' => 'sometimes|required', + ]; + } + + /** + * Get remove action validation rules. + * + * @param Model $model + * @return array + */ + public function removeRules(Model $model) + { + return []; + } +} +``` + +### Model Namespace Option + +In this example, we will pass a `--model-namespace` option to set the model namespace to be used by our DataTable. + +```bash +php artisan datatables:editor Posts --model-namespace="Entities" +``` + +It will implicitly activate `--model` option and override the `model` parameter in `datatables-buttons` config file. +This will allow to use a non-standard namespace if front-end and back-end models are in separate namespace for example. diff --git a/editor-events.md b/editor-events.md new file mode 100644 index 0000000..b95f180 --- /dev/null +++ b/editor-events.md @@ -0,0 +1,60 @@ +# DataTables Editor Event Hooks + +In addition to Laravel's model events, DataTables Editor offers some pre & post event hooks. + +## Create Events + +Create action has the following event hooks: + +- [creating] event hook that is fired before creating a new record. +- [created] event hook that is fired after the record was created. + +To use the event hook, just add the methods on your editor class. + +```php +public function creating(Model $model, array $data) { + return $data; +} + +public function created(Model $model, array $data) { + return $data; +} +``` + +## Edit Events + +Edit action has the following event hooks: + +- [updating] event hook that is fired before updating a new record. +- [updated] event hook that is fired after the record was updated. + +To use the event hook, just add the methods on your editor class. + +```php +public function updating(Model $model, array $data) { + return $data; +} + +public function updated(Model $model, array $data) { + return $data; +} +``` + +## Remove Events + +Remove action has the following event hooks: + +- [deleting] event hook that is fired before deleting a new record. +- [deleted] event hook that is fired after the record was deleted. + +To use the event hook, just add the methods on your editor class. + +```php +public function deleting(Model $model, array $data) { + return $data; +} + +public function deleted(Model $model, array $data) { + return $data; +} +``` diff --git a/editor-installation.md b/editor-installation.md new file mode 100644 index 0000000..63b7688 --- /dev/null +++ b/editor-installation.md @@ -0,0 +1,26 @@ +# Laravel DataTables Editor Plugin + +This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for processing [DataTables Editor](https://editor.datatables.net/) integration. + +## Installation + +> Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. + +Run the following command in your project to get the latest version of the plugin: + +`composer require yajra/laravel-datatables-editor:^1.0` + +## Configuration + +> This step is optional if you are using Laravel 5.5 + +Open the file ```config/app.php``` and then add following service provider. + +```php +'providers' => [ + // ... + Yajra\DataTables\EditorServiceProvider::class, +], +``` + +And that's it! Start building out some awesome DataTables Editor! diff --git a/editor-rules.md b/editor-rules.md new file mode 100644 index 0000000..04c3092 --- /dev/null +++ b/editor-rules.md @@ -0,0 +1,39 @@ +# DataTables Editor Rules + +DataTables Editor requires three (3) rules for create, edit and remove action respectively. + +## Create Rules + +This are the rules that will be used when validating a create action. + +```php +public function createRules() { + return [ + 'email' => 'required|email|unique:users', + 'name' => 'required', + ]; +} +``` + +## Edit Rules + +This are the rules that will be used when validating an edit action. + +```php +public function editRules(Model $model) { + return [ + 'email' => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()), + 'first_name' => 'sometimes|required', + ]; +} +``` + +## Remove Rules + +This are the rules that will be used when validating a remove action. + +```php +public function removeRules(Model $model) { + return []; +} +``` From 4fba14eea8e5dab57702607dea7be5ac42dd4fca Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:17:51 +0800 Subject: [PATCH 101/264] Fix title and special thanks. --- editor-installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/editor-installation.md b/editor-installation.md index 63b7688..5df2d93 100644 --- a/editor-installation.md +++ b/editor-installation.md @@ -1,11 +1,11 @@ -# Laravel DataTables Editor Plugin +# DataTables Editor Plugin This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for processing [DataTables Editor](https://editor.datatables.net/) integration. -## Installation - > Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. +## Installation + Run the following command in your project to get the latest version of the plugin: `composer require yajra/laravel-datatables-editor:^1.0` From 4691131090be19eb7942a9ec03b8feab8e5df890 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:18:45 +0800 Subject: [PATCH 102/264] Fix options list. --- editor-command.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor-command.md b/editor-command.md index b8d336f..a160e34 100644 --- a/editor-command.md +++ b/editor-command.md @@ -18,8 +18,8 @@ php artisan datatables:editor {name} ## Editor Command Options -`--model` : The name given will be used as the model is singular form. -`--model-namespace` : The namespace of the model to be used. +- `--model` : The name given will be used as the model is singular form. +- `--model-namespace` : The namespace of the model to be used. ## Creating a DataTables Editor class From b44ce7b6daa5055db9308c20690e77f3bb65d0f8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:22:18 +0800 Subject: [PATCH 103/264] Add doc links. --- editor-command.md | 5 +++++ editor-events.md | 3 +++ editor-installation.md | 2 ++ editor-rules.md | 3 +++ 4 files changed, 13 insertions(+) diff --git a/editor-command.md b/editor-command.md index a160e34..5f9e646 100644 --- a/editor-command.md +++ b/editor-command.md @@ -10,17 +10,20 @@ To view a list of all available Artisan commands, you may use the list command: php artisan list ``` + ## Editor Command ```bash php artisan datatables:editor {name} ``` + ## Editor Command Options - `--model` : The name given will be used as the model is singular form. - `--model-namespace` : The namespace of the model to be used. + ## Creating a DataTables Editor class In this example, we will create a DataTable Editor class. @@ -83,6 +86,7 @@ class PostsDataTableEditor extends DataTablesEditor } ``` + ### Model Option In this example, we will pass a `--model` option to set the model to be used by our DataTable. @@ -146,6 +150,7 @@ class PostsDataTableEditor extends DataTablesEditor } ``` + ### Model Namespace Option In this example, we will pass a `--model-namespace` option to set the model namespace to be used by our DataTable. diff --git a/editor-events.md b/editor-events.md index b95f180..c7b3e76 100644 --- a/editor-events.md +++ b/editor-events.md @@ -2,6 +2,7 @@ In addition to Laravel's model events, DataTables Editor offers some pre & post event hooks. + ## Create Events Create action has the following event hooks: @@ -21,6 +22,7 @@ public function created(Model $model, array $data) { } ``` + ## Edit Events Edit action has the following event hooks: @@ -40,6 +42,7 @@ public function updated(Model $model, array $data) { } ``` + ## Remove Events Remove action has the following event hooks: diff --git a/editor-installation.md b/editor-installation.md index 5df2d93..09bba42 100644 --- a/editor-installation.md +++ b/editor-installation.md @@ -4,12 +4,14 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave > Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. + ## Installation Run the following command in your project to get the latest version of the plugin: `composer require yajra/laravel-datatables-editor:^1.0` + ## Configuration > This step is optional if you are using Laravel 5.5 diff --git a/editor-rules.md b/editor-rules.md index 04c3092..e467aa5 100644 --- a/editor-rules.md +++ b/editor-rules.md @@ -2,6 +2,7 @@ DataTables Editor requires three (3) rules for create, edit and remove action respectively. + ## Create Rules This are the rules that will be used when validating a create action. @@ -15,6 +16,7 @@ public function createRules() { } ``` + ## Edit Rules This are the rules that will be used when validating an edit action. @@ -28,6 +30,7 @@ public function editRules(Model $model) { } ``` + ## Remove Rules This are the rules that will be used when validating a remove action. From e19d400ea92aa69bcfc26f9d86179ae0bb2290ee Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:24:26 +0800 Subject: [PATCH 104/264] Fix typo. --- editor-command.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor-command.md b/editor-command.md index 5f9e646..cb6ff9c 100644 --- a/editor-command.md +++ b/editor-command.md @@ -32,7 +32,7 @@ In this example, we will create a DataTable Editor class. php artisan datatables:editor Posts ``` -This will create an `PostsDataTableEditor` class on `app\DataTables` directory. +This will create a `PostsDataTableEditor` class on `app\DataTables` directory. ```php namespace App\DataTables; From feb4028d898b67f5f65fbd15fb20d2f93e4eb4a8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:28:04 +0800 Subject: [PATCH 105/264] Add notes on premium license for editor. --- editor-installation.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor-installation.md b/editor-installation.md index 09bba42..112ac30 100644 --- a/editor-installation.md +++ b/editor-installation.md @@ -1,8 +1,10 @@ # DataTables Editor Plugin -This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for processing [DataTables Editor](https://editor.datatables.net/) integration. +This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for processing [DataTables Editor](https://editor.datatables.net/) library. -> Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. +> {info} Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. + +> A [premium license](https://editor.datatables.net/purchase/index) is required to be able to use [DataTables Editor](https://editor.datatables.net/) library. ## Installation From eb17ad95c4aa32031e90890bd9520b6c5d95979e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 16 Dec 2017 23:55:18 +0800 Subject: [PATCH 106/264] Add editor usage docs. --- documentation.md | 1 + editor-usage.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 editor-usage.md diff --git a/documentation.md b/documentation.md index 4a53c16..792a0f7 100644 --- a/documentation.md +++ b/documentation.md @@ -89,4 +89,5 @@ - [Editor Command](/docs/{{package}}/{{version}}/editor-command) - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) + - [Usage](/docs/{{package}}/{{version}}/editor-usage) - [Github](https://github.com/yajra/laravel-datatables-editor) \ No newline at end of file diff --git a/editor-usage.md b/editor-usage.md new file mode 100644 index 0000000..99acd4d --- /dev/null +++ b/editor-usage.md @@ -0,0 +1,33 @@ +# Using DataTables Editor + +All actions requested by DataTables Editor are being submitted via `POST` ajax request. +This means, that we need to create a `post` request route that will handle all the actions we need. + +> {info} This doc assumes that you are already knowlegeable of [DataTables Editor](https://editor.datatables.net/examples/index) library. + +## Create your Editor + +You can create your editor using [artisan command](/docs/{{package}}/{{version}}/editor-command). + +```bash +php artisan datatables:editor Users +``` + +## Setup Editor Rules + +See [editor rules](/docs/{{package}}/{{version}}/editor-rules) docs for ref: + +## Register Route Handler + +```php +use App\DataTables\UsersDataTablesEditor; + +Route::post('editor', function(UsersDataTablesEditor $editor) { + return $editor->process(request()); +}); +``` + +## Setup your content + +You can use [DataTables Editor Genetor](https://editor.datatables.net/generator/index) to help you speed-up the process. +Once generated, copy the necessary scripts and html on your blade template. From d814dbaa03c003ea56c25b71b3707181e3b707d8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 17 Dec 2017 00:02:32 +0800 Subject: [PATCH 107/264] Add CSRF token docs. --- editor-usage.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/editor-usage.md b/editor-usage.md index 99acd4d..2a5dc95 100644 --- a/editor-usage.md +++ b/editor-usage.md @@ -3,8 +3,9 @@ All actions requested by DataTables Editor are being submitted via `POST` ajax request. This means, that we need to create a `post` request route that will handle all the actions we need. -> {info} This doc assumes that you are already knowlegeable of [DataTables Editor](https://editor.datatables.net/examples/index) library. +> This doc assumes that you are already knowlegeable of [DataTables Editor](https://editor.datatables.net/examples/index) library. + ## Create your Editor You can create your editor using [artisan command](/docs/{{package}}/{{version}}/editor-command). @@ -13,10 +14,12 @@ You can create your editor using [artisan command](/docs/{{package}}/{{version}} php artisan datatables:editor Users ``` + ## Setup Editor Rules See [editor rules](/docs/{{package}}/{{version}}/editor-rules) docs for ref: + ## Register Route Handler ```php @@ -27,6 +30,21 @@ Route::post('editor', function(UsersDataTablesEditor $editor) { }); ``` + +## Setup AJAX csrf-token + +Since actions are being sent via `post`, we need to make sure that we setup [csrf-token](https://laravel.com/docs/csrf#csrf-x-csrf-token). +Just add the snippets below before your scripts to avoid csrf errors: + +```js +$.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + } +}); +``` + + ## Setup your content You can use [DataTables Editor Genetor](https://editor.datatables.net/generator/index) to help you speed-up the process. From 4c0edb97e0f03d6cdee142a14e8cd8cb6bc81e33 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 17 Dec 2017 00:03:31 +0800 Subject: [PATCH 108/264] Fix typo. --- editor-usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor-usage.md b/editor-usage.md index 2a5dc95..ed12f63 100644 --- a/editor-usage.md +++ b/editor-usage.md @@ -47,5 +47,5 @@ $.ajaxSetup({ ## Setup your content -You can use [DataTables Editor Genetor](https://editor.datatables.net/generator/index) to help you speed-up the process. +You can use [DataTables Editor Generator](https://editor.datatables.net/generator/index) to help you speed-up the process. Once generated, copy the necessary scripts and html on your blade template. From 44fff9be29ae5d518b0e7e11787266cebf628e19 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 17 Dec 2017 00:10:44 +0800 Subject: [PATCH 109/264] Add editor model docs. --- documentation.md | 1 + editor-model.md | 21 +++++++++++++++++++++ editor-usage.md | 5 +++++ 3 files changed, 27 insertions(+) create mode 100644 editor-model.md diff --git a/documentation.md b/documentation.md index 792a0f7..1eb57bf 100644 --- a/documentation.md +++ b/documentation.md @@ -87,6 +87,7 @@ - ## Editor - [Installation](/docs/{{package}}/{{version}}/editor-installation) - [Editor Command](/docs/{{package}}/{{version}}/editor-command) + - [Editor Model](/docs/{{package}}/{{version}}/editor-model) - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) - [Usage](/docs/{{package}}/{{version}}/editor-usage) diff --git a/editor-model.md b/editor-model.md new file mode 100644 index 0000000..37a5475 --- /dev/null +++ b/editor-model.md @@ -0,0 +1,21 @@ +# DataTables Editor Model + +DataTables Editor requires aa `Eloquent Model` that will be used for our CRUD operations. + +> All CRUD operations of Editor uses database transaction. + + +## Setup Model + +Just set the `$model` property of your editor class to your model's FQCN. + +```php +namespace App\DataTables\Editors; + +use App\User; +use Yajra\DataTables\DataTablesEditor; + +class UsersDataTablesEditor extends DataTablesEditor +{ + protected $model = User::class; +} diff --git a/editor-usage.md b/editor-usage.md index ed12f63..ea02189 100644 --- a/editor-usage.md +++ b/editor-usage.md @@ -14,6 +14,11 @@ You can create your editor using [artisan command](/docs/{{package}}/{{version}} php artisan datatables:editor Users ``` + +## Setup Editor Model + +See [editor model](/docs/{{package}}/{{version}}/editor-model) docs for ref: + ## Setup Editor Rules From df5242f7d3f83d1fc8ba20925357482a00a77531 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 17 Dec 2017 00:11:44 +0800 Subject: [PATCH 110/264] Fix typo. --- editor-model.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor-model.md b/editor-model.md index 37a5475..2a1a14c 100644 --- a/editor-model.md +++ b/editor-model.md @@ -1,6 +1,6 @@ # DataTables Editor Model -DataTables Editor requires aa `Eloquent Model` that will be used for our CRUD operations. +DataTables Editor requires a `Eloquent Model` that will be used for our CRUD operations. > All CRUD operations of Editor uses database transaction. From 5ba3c27174f9549206da14d599a432ff2d6a87d3 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 17 Dec 2017 00:15:50 +0800 Subject: [PATCH 111/264] Fix tips. --- editor-events.md | 12 ++++++------ editor-installation.md | 4 ++-- editor-model.md | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/editor-events.md b/editor-events.md index c7b3e76..e830981 100644 --- a/editor-events.md +++ b/editor-events.md @@ -7,8 +7,8 @@ In addition to Laravel's model events, DataTables Editor offers some pre & post Create action has the following event hooks: -- [creating] event hook that is fired before creating a new record. -- [created] event hook that is fired after the record was created. +- `creating` event hook that is fired before creating a new record. +- `created` event hook that is fired after the record was created. To use the event hook, just add the methods on your editor class. @@ -27,8 +27,8 @@ public function created(Model $model, array $data) { Edit action has the following event hooks: -- [updating] event hook that is fired before updating a new record. -- [updated] event hook that is fired after the record was updated. +- `updating` event hook that is fired before updating a new record. +- `updated` event hook that is fired after the record was updated. To use the event hook, just add the methods on your editor class. @@ -47,8 +47,8 @@ public function updated(Model $model, array $data) { Remove action has the following event hooks: -- [deleting] event hook that is fired before deleting a new record. -- [deleted] event hook that is fired after the record was deleted. +- `deleting` event hook that is fired before deleting a new record. +- `deleted` event hook that is fired after the record was deleted. To use the event hook, just add the methods on your editor class. diff --git a/editor-installation.md b/editor-installation.md index 112ac30..c4c95b6 100644 --- a/editor-installation.md +++ b/editor-installation.md @@ -2,9 +2,9 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/laravel-datatables) for processing [DataTables Editor](https://editor.datatables.net/) library. -> {info} Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. +> {tip} Special thanks to [@bellwood](https://github.com/bellwood) and [@DataTables](https://github.com/datatables) for being [generous](https://github.com/yajra/laravel-datatables/issues/1548) for providing a license to support the development of this package. -> A [premium license](https://editor.datatables.net/purchase/index) is required to be able to use [DataTables Editor](https://editor.datatables.net/) library. +A [premium license](https://editor.datatables.net/purchase/index) is required to be able to use [DataTables Editor](https://editor.datatables.net/) library. ## Installation diff --git a/editor-model.md b/editor-model.md index 2a1a14c..0b78dd3 100644 --- a/editor-model.md +++ b/editor-model.md @@ -2,7 +2,7 @@ DataTables Editor requires a `Eloquent Model` that will be used for our CRUD operations. -> All CRUD operations of Editor uses database transaction. +> {tip} All CRUD operations of Editor uses database transaction. ## Setup Model From 5cd75cebbf52295111f6a2277604b1b020c924a4 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Dec 2017 17:35:27 +0800 Subject: [PATCH 112/264] Add notes about models fillable property. --- editor-model.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/editor-model.md b/editor-model.md index 0b78dd3..253aa64 100644 --- a/editor-model.md +++ b/editor-model.md @@ -19,3 +19,20 @@ class UsersDataTablesEditor extends DataTablesEditor { protected $model = User::class; } +``` + +## IMPORTANT + +> Don't forget to set your model's fillable property. The Editor's basic crud operation relies on this. + +```php +namespace App; + +class User extends Model { + protected $fillable = [ + 'name', + 'email', + 'password', + ]; +} +``` \ No newline at end of file From b53faeec2487ed86c04b0e69d1a37d4028bbc489 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Dec 2017 17:36:37 +0800 Subject: [PATCH 113/264] Remove namesapce. --- editor-model.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/editor-model.md b/editor-model.md index 253aa64..2901e8f 100644 --- a/editor-model.md +++ b/editor-model.md @@ -26,8 +26,6 @@ class UsersDataTablesEditor extends DataTablesEditor > Don't forget to set your model's fillable property. The Editor's basic crud operation relies on this. ```php -namespace App; - class User extends Model { protected $fillable = [ 'name', From 16114f2f4ece7ac7b13408e9c660a871ddf5aebc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Dec 2017 17:38:29 +0800 Subject: [PATCH 114/264] Add link to event hooks. --- editor-model.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/editor-model.md b/editor-model.md index 2901e8f..31166f6 100644 --- a/editor-model.md +++ b/editor-model.md @@ -21,9 +21,10 @@ class UsersDataTablesEditor extends DataTablesEditor } ``` -## IMPORTANT +## Fillable Property -> Don't forget to set your model's fillable property. The Editor's basic crud operation relies on this. +Don't forget to set your model's fillable property. The Editor's basic crud operation relies on this. +For advance operations like saving relations, use the [Editors Event Hooks](/docs/{{package}}/{{version}}/editor-events). ```php class User extends Model { From 1b57388c0e6f97c0b781c43c68a88367178ea633 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 18 Dec 2017 19:43:07 +0800 Subject: [PATCH 115/264] Add editor tutorial. --- documentation.md | 1 + editor-tutorial.md | 336 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 337 insertions(+) create mode 100644 editor-tutorial.md diff --git a/documentation.md b/documentation.md index 1eb57bf..4d4d11a 100644 --- a/documentation.md +++ b/documentation.md @@ -91,4 +91,5 @@ - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) - [Usage](/docs/{{package}}/{{version}}/editor-usage) + - [Tutorial](/docs/{{package}}/{{version}}/editor-tutorial) - [Github](https://github.com/yajra/laravel-datatables-editor) \ No newline at end of file diff --git a/editor-tutorial.md b/editor-tutorial.md new file mode 100644 index 0000000..4afcef5 --- /dev/null +++ b/editor-tutorial.md @@ -0,0 +1,336 @@ +# Creating a Laravel Full CRUD with DataTables Editor. + +Before we begin, please be reminded that the Editor library that we are going to use here requires a paid license. +See [DataTables Editor](https://editor.datatables.net/purchase/index) for details. + +## Create a new laravel app + +Using [laravel installer](https://laravel.com/docs/5.5/installation), run the command below using terminal. + +```bash +laravel new editor +``` + +Once installed, lets configure our application and use `sqlite` as our database by updating `DB_CONNECTION=sqlite`. +We also need to remove the following lines as it is not needed for sqlite. + +```php +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=homestead +DB_USERNAME=homestead +DB_PASSWORD=secret +``` + +Next, create our database and run the migration. We will then seed some users using tinker. + +```bash +cd editor +touch database/database.sqlite +php artisan migrate +php artisan tinker +>>> factory(App\User::class, 20)->create(); +``` + +## Install DataTables Editor library. + +In this step, we will only need to install `yajra/laravel-datatables-editor`. + +```bash +composer require yajra/laravel-datatables-editor +``` + +## Create Controllers, DataTables and Editor classes. + +```php +php artisan make:controller UsersController +php artisan datatables:make Users +php artisan datatables:editor Users +``` + +These commands will generate the following files: +- app\Http\Controllers\UsersController.php +- app\DataTables\UsersDataTable.php +- app\DataTables\UsersDataTablesEditor.php + +## Setup Controller + +We will only need `index` and `store` method for our controller. But before that, lets register our route first on `routes\web.php` + +```php +Route::resource('users', 'UsersController'); +``` + +Will now add the methods on our controller. + +```php +render('users.index'); + } + + public function store(UsersDataTablesEditor $editor) + { + return $editor->process(request()); + } +} +``` + +## Setup DataTable + +```php +setRowId('id')->addColumn('password', ''); + } + + /** + * Get query source of dataTable. + * + * @param \App\User $model + * @return \Illuminate\Database\Eloquent\Builder + */ + public function query(User $model) + { + return $model->newQuery()->select('id', 'name', 'email'); + } + + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\DataTables\Html\Builder + */ + public function html() + { + return $this->builder() + ->columns($this->getColumns()) + ->minifiedAjax() + ->parameters([ + 'dom' => 'Bfrtip', + 'order' => [1, 'asc'], + 'select' => [ + 'style' => 'os', + 'selector' => 'td:first-child', + ], + 'buttons' => [ + ['extend' => 'create', 'editor' => 'editor'], + ['extend' => 'edit', 'editor' => 'editor'], + ['extend' => 'remove', 'editor' => 'editor'], + ] + ]); + } + + /** + * Get columns. + * + * @return array + */ + protected function getColumns() + { + return [ + [ + 'data' => null, + 'defaultContent' => '', + 'className' => 'select-checkbox', + 'title' => '', + 'orderable' => false, + 'searchable' => false + ], + 'id', + 'name', + 'email', + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename() + { + return 'users_' . time(); + } +} +``` + +## Setup Editor + +```php + 'required|email|unique:users', + 'name' => 'required', + ]; + } + + /** + * Get edit action validation rules. + * + * @param Model $model + * @return array + */ + public function editRules(Model $model) + { + return [ + 'email' => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()), + 'name' => 'sometimes|required', + ]; + } + + /** + * Get remove action validation rules. + * + * @param Model $model + * @return array + */ + public function removeRules(Model $model) + { + return []; + } + + public function creating(Model $model, array $data) + { + $data['password'] = bcrypt($data['password']); + + return $data; + } + + public function updating(Model $model, array $data) + { + if (empty($data['password'])) { + unset($data['password']); + } else { + $data['password'] = bcrypt($data['password']); + } + + return $data; + } +} +``` + +## Setup View + +Lets create our users admin panel view at `resources/views/users/index.blade.php`. + +```php + + + + + + + + Laravel DataTables Editor + + + + + + + + + + + + + + + + + + + + + +
+ {{$dataTable->table(['id' => 'users'])}} +
+ + + + +``` + +## Register and Download your trial Editor library + +You can download the library assets [here](https://editor.datatables.net/download/) once you successfully registered to DataTables. +We would only need the JS and CSS so I suggest you only download those files. +Once downloaded, copy the library to `public/plugins/editor` of your laravel public directory. + +## Run your application + +Using valet, visit your site using `http://editor.dev/users` and see the full CRUD in action. + +## Gist + +See this [gist](https://gist.github.com/yajra/38ee8d2521fa419309dfabcb667d9c2a) for the complete source code of added files. From 58b398e472047ec410f62e70a809e1512382a4f1 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 23 Dec 2017 22:36:17 +0800 Subject: [PATCH 116/264] Update default generator. --- buttons-config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buttons-config.md b/buttons-config.md index 9887c42..5b4260d 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -37,12 +37,12 @@ Set the PDF generator to be used when converting your dataTable to pdf. Available generators are: `excel`, `snappy` -### Excel Generator (Default Generator) +### Excel Generator When `excel` is used as the generator, the package will use [`maatwebsite/excel`](http://www.maatwebsite.nl/laravel-excel/docs) 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 +### Snappy Generator (Default Generator) When `snappy` is used as the generator, you need to install [`barryvdh/laravel-snappy`](https://github.com/barryvdh/laravel-snappy) ### Snappy PDF Options From 3112a867593c6a77208e822966109a345596908e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 24 Dec 2017 17:21:56 +0800 Subject: [PATCH 117/264] Add docblocks. --- editor-tutorial.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor-tutorial.md b/editor-tutorial.md index 4afcef5..2cf0fcb 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -233,6 +233,12 @@ class UsersDataTablesEditor extends DataTablesEditor return []; } + /** + * Pre-create action event hook. + * + * @param Model $model + * @return array + */ public function creating(Model $model, array $data) { $data['password'] = bcrypt($data['password']); @@ -240,6 +246,12 @@ class UsersDataTablesEditor extends DataTablesEditor return $data; } + /** + * Pre-update action event hook. + * + * @param Model $model + * @return array + */ public function updating(Model $model, array $data) { if (empty($data['password'])) { From 29f0be783ed9115f4415a498a054d2551007717a Mon Sep 17 00:00:00 2001 From: BlackCaptainTR <6266078+BlackCaptainTR@users.noreply.github.com> Date: Wed, 21 Mar 2018 00:19:18 +0300 Subject: [PATCH 118/264] Little changes about Laravel version --- installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installation.md b/installation.md index 085d2ba..b4b5216 100644 --- a/installation.md +++ b/installation.md @@ -11,7 +11,7 @@ ### Requirements -- [Laravel 5.5](https://github.com/laravel/framework) +- [Laravel 5.5+](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) @@ -33,7 +33,7 @@ composer require yajra/laravel-datatables:^1.0 ### Configuration -> This step is optional if you are using Laravel 5.5 +> This step is optional if you are using Laravel 5.5+ Open the file ```config/app.php``` and then add following service provider. From 157a8e99ad3bddaa2d8b44126b9b7acdf8181611 Mon Sep 17 00:00:00 2001 From: BlackCaptainTR <6266078+BlackCaptainTR@users.noreply.github.com> Date: Wed, 21 Mar 2018 00:29:37 +0300 Subject: [PATCH 119/264] Add documentation for make:transformer command --- response-fractal.md | 111 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/response-fractal.md b/response-fractal.md index f0a8b43..5ecef13 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -16,7 +16,13 @@ Route::get('user-data', function() { }); ``` -Create your transformer. `app\Transformers\UserTransformer.php` +## Creating Transformer + +### Manual Way + +Create a transformer class, preferably named as below. + +`app\Transformers\UserTransformer.php` ```php namespace App\Transformers; @@ -55,3 +61,106 @@ class UserTransformer extends TransformerAbstract } } ``` + +### Artisan Command Way + +You can use `make:transformer` command to generate boilerplate. + +`php artisan make:transformer User` + +```php +namespace App\Transformers; + +use League\Fractal\TransformerAbstract; +use App\User; + +class UserTransformer extends TransformerAbstract +{ + /** + * @param \App\User $user + * @return array + */ + public function transform(User $user) + { + return [ + 'id' => (int) $user->id, + ]; + } +} +``` + +Or even with included class. + +`php artisan make:transformer User Post` + +```php +namespace App\Transformers; + +use League\Fractal\TransformerAbstract; +use App\User; +use App\Post; + +class UserTransformer extends TransformerAbstract +{ + protected $availableIncludes = ['post']; + + /** + * @param \App\User $user + * @return array + */ + public function transform(User $user) + { + return [ + 'id' => (int) $user->id, + ]; + } + + /** + * @param \App\User $user + * @return \League\Fractal\Resource\Collection + */ + public function includePost(User $user) + { + return $this->collection($user->post, new PostTransformer); + } +} +``` + +Then you can make final changes. + +```php +namespace App\Transformers; + +use League\Fractal\TransformerAbstract; +use App\User; +use App\Post; + +class UserTransformer extends TransformerAbstract +{ + protected $availableIncludes = ['posts']; + + /** + * @param \App\User $user + * @return array + */ + public function transform(User $user) + { + return [ + 'id' => (int) $user->id, + 'name' => $user->name, + 'email' => $user->email, + 'created_at' => (string) $user->created_at, + 'updated_at' => (string) $user->updated_at, + ]; + } + + /** + * @param \App\User $user + * @return \League\Fractal\Resource\Collection + */ + public function includePost(User $user) + { + return $this->collection($user->posts, new PostTransformer); + } +} +``` \ No newline at end of file From f009889b43f2f98ac083ee68568755fb11929f26 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 29 Mar 2018 00:06:35 +0800 Subject: [PATCH 120/264] Update docs as per issue: https://github.com/yajra/laravel-datatables/issues/1673#issuecomment-376939850 --- manual-search.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual-search.md b/manual-search.md index ce521b1..9cefdbe 100644 --- a/manual-search.md +++ b/manual-search.md @@ -15,11 +15,11 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { - $query->where('name', 'like', "%{request('name')}%"); + $query->where('name', 'like', "%" . request('name') . "%"); } if (request()->has('email')) { - $query->where('email', 'like', "%{request('email')}%"); + $query->where('email', 'like', "%" . request('email') . "%"); } }) ->toJson(); From f6711001e5788de523cd312475e4078897efd236 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 29 Mar 2018 00:07:16 +0800 Subject: [PATCH 121/264] Update param. --- manual-search.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manual-search.md b/manual-search.md index 9cefdbe..94fec6c 100644 --- a/manual-search.md +++ b/manual-search.md @@ -40,11 +40,11 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->filter(function ($query) { if (request()->has('name')) { - $query->where('name', 'like', "%{request('name')}%"); + $query->where('name', 'like', "%" . request('name') . "%"); } if (request()->has('email')) { - $query->where('email', 'like', "%{request('email')}%"); + $query->where('email', 'like', "%" . request('email') . "%"); } }, true) ->toJson(); From de544b7713345ff8238b675a6bea3f6bcfbd4193 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 22 May 2018 17:24:29 -0400 Subject: [PATCH 122/264] Add link to setFilteredRecords documentation. --- documentation.md | 1 + set-filtered-records.md | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 set-filtered-records.md diff --git a/documentation.md b/documentation.md index 4d4d11a..01bfc48 100644 --- a/documentation.md +++ b/documentation.md @@ -53,6 +53,7 @@ - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) + - [Set Filtered Records](/docs/{{package}}/{{version}}/set-filtered-records) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) ### PLUGINS diff --git a/set-filtered-records.md b/set-filtered-records.md new file mode 100644 index 0000000..5a45176 --- /dev/null +++ b/set-filtered-records.md @@ -0,0 +1,16 @@ +# Set Filtered Records + +In some cases, we need to manually set the filtered records count of our `DataTables` and skip its internal counting functionality. +To achieve this, we can use `setFilteredRecords($count)` api. + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->setFilteredRecords(100) + ->toJson(); +}); +``` From 59dc0622c9fc611c61028c1635a6424f494a861b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 3 Jun 2018 08:59:22 +0800 Subject: [PATCH 123/264] Add with closure docs. --- response-with.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/response-with.md b/response-with.md index e4fe5d6..405873d 100644 --- a/response-with.md +++ b/response-with.md @@ -36,6 +36,25 @@ Route::get('user-data', function() { }); ``` + +## Adding response using closure with filtered query. + +> This is for Query and Eloquent instance only, + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->with('count', function($query) { + return $query->count(); + }) + ->toJson(); +}); +``` + ## Example Response From 54f420dc49720864858e63df12c03c3b821c055e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 3 Jun 2018 09:29:20 +0800 Subject: [PATCH 124/264] Add withQuery api doc. --- response-with.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/response-with.md b/response-with.md index 405873d..21e7ca0 100644 --- a/response-with.md +++ b/response-with.md @@ -37,7 +37,7 @@ Route::get('user-data', function() { ``` -## Adding response using closure with filtered query. +## Adding response with closure. > This is for Query and Eloquent instance only, @@ -48,8 +48,27 @@ Route::get('user-data', function() { $model = App\User::query(); return DataTables::eloquent($model) - ->with('count', function($query) { - return $query->count(); + ->with('count', function() { + return $model->count(); + }) + ->toJson(); +}); +``` + + +## Adding response with query callback. + +> This is for Query and Eloquent instance only, + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->withQuery('count', function($filteredQuery) { + return $filteredQuery->count(); }) ->toJson(); }); From 6dfc985d25e76e4757995064313956c286394079 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sun, 3 Jun 2018 09:35:21 +0800 Subject: [PATCH 125/264] Remove note. --- response-with.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/response-with.md b/response-with.md index 21e7ca0..6d5b22c 100644 --- a/response-with.md +++ b/response-with.md @@ -39,8 +39,6 @@ Route::get('user-data', function() { ## Adding response with closure. -> This is for Query and Eloquent instance only, - ```php use DataTables; From ac7a5dc6716812ac3254a922c6a3f2f4b72b431c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 4 Jun 2018 11:26:30 +0800 Subject: [PATCH 126/264] Fix closue use model. --- response-with.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/response-with.md b/response-with.md index 6d5b22c..f84221e 100644 --- a/response-with.md +++ b/response-with.md @@ -46,7 +46,7 @@ Route::get('user-data', function() { $model = App\User::query(); return DataTables::eloquent($model) - ->with('count', function() { + ->with('count', function() use ($model) { return $model->count(); }) ->toJson(); From 363d202e6b6e84722ff25b66dfeefb7c30e40c0c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Tue, 2 Oct 2018 11:02:38 +0800 Subject: [PATCH 127/264] Add export column Docs --- export-column.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 export-column.md diff --git a/export-column.md b/export-column.md new file mode 100644 index 0000000..8fddc50 --- /dev/null +++ b/export-column.md @@ -0,0 +1,12 @@ +# Export Column + +You can export a column customised header if manually set. + + +## Export Column + +```php + protected $exportColumns = [ + ['data' => 'email', 'title' => 'Registered Email], + ]; +``` \ No newline at end of file From 2a70d676c3072e5c456431559c6dc780e42790a7 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Tue, 2 Oct 2018 11:43:54 +0800 Subject: [PATCH 128/264] Add print column --- print-column.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 print-column.md diff --git a/print-column.md b/print-column.md new file mode 100644 index 0000000..0b0088f --- /dev/null +++ b/print-column.md @@ -0,0 +1,12 @@ +# Print Column + +You can print a column customised header if manually set. + + +## Print Column + +```php + protected $printColumns = [ + ['data' => 'email', 'title' => 'Registered Email], + ]; +``` \ No newline at end of file From 7f16060bfceae27e48e51e577ea7bb5d19e1af04 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Tue, 2 Oct 2018 12:06:13 +0800 Subject: [PATCH 129/264] Add menu link for documentation export columns --- documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.md b/documentation.md index bc24693..f622069 100644 --- a/documentation.md +++ b/documentation.md @@ -32,6 +32,7 @@ - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) + - [Export Columns](/docs/{{package}}/{{version}}/export-columns) - Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) From e2c87b91f159d303c7b8333df095b8c872c1c95f Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Tue, 2 Oct 2018 12:08:59 +0800 Subject: [PATCH 130/264] Add menu link for documentation print columns --- documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.md b/documentation.md index bc24693..0332c7e 100644 --- a/documentation.md +++ b/documentation.md @@ -32,6 +32,7 @@ - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) + - [Print Columns](/docs/{{package}}/{{version}}/print-columns) - Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) From 740c6cb8f135b46ffeec40f8de6d1c8ca8753be7 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 2 Oct 2018 14:37:48 +0800 Subject: [PATCH 131/264] Add new line after each section. --- documentation.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/documentation.md b/documentation.md index 01bfc48..cfb82ae 100644 --- a/documentation.md +++ b/documentation.md @@ -4,50 +4,60 @@ - [Contribution Guide](/docs/{{package}}/{{version}}/contributing) - [Security Issues](/docs/{{package}}/{{version}}/security) - [API Documentation](http://yajra.github.io/{{package}}/api/{{version}}) + - ## Getting Started - [Introduction](/docs/{{package}}/{{version}}/introduction) - [Installation](/docs/{{package}}/{{version}}/installation) - [Demo Application](https://datatables.yajrabox.com/) + - ## Tutorials - [Quick Starter](https://datatables.yajrabox.com/starter) - [Service Implementation](https://datatables.yajrabox.com/service) + - ## Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) - [Debugging Mode](/docs/{{package}}/{{version}}/debugger) - [Error Handler](/docs/{{package}}/{{version}}/error-handler) + - ## DataTables Classes - [Eloquent](/docs/{{package}}/{{version}}/engine-eloquent) - [Query Builder](/docs/{{package}}/{{version}}/engine-query) - [Collection](/docs/{{package}}/{{version}}/engine-collection) + - ## Response - [Array Response](/docs/{{package}}/{{version}}/response-array) - [Object Response](/docs/{{package}}/{{version}}/response-object) - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) + - ## Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) - [Edit Column](/docs/{{package}}/{{version}}/edit-column) - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) + - ## Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) - [Row Class](/docs/{{package}}/{{version}}/row-options#row-class) - [Row Data](/docs/{{package}}/{{version}}/row-options#row-data) - [Row Attributes](/docs/{{package}}/{{version}}/row-options#row-attributes) + - ## Searching - [Manual Search](/docs/{{package}}/{{version}}/manual-search) - [Filter Column](/docs/{{package}}/{{version}}/filter-column) - [Regex Search](/docs/{{package}}/{{version}}/regex) - [Smart Search](/docs/{{package}}/{{version}}/smart-search) - [Relationships](/docs/{{package}}/{{version}}/relationships) + - ## Sorting/Ordering - [Manual Order](/docs/{{package}}/{{version}}/manual-order) - [Order Column](/docs/{{package}}/{{version}}/order-column) - [Order Columns](/docs/{{package}}/{{version}}/order-columns) - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) + - ## Utilities - [XSS filtering](/docs/{{package}}/{{version}}/xss) - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) From 238c7a7c6799af08761353d0c359e9c472c4748a Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 2 Oct 2018 14:41:49 +0800 Subject: [PATCH 132/264] Add section for community links. --- community-links.md | 6 ++++++ documentation.md | 1 + 2 files changed, 7 insertions(+) create mode 100644 community-links.md diff --git a/community-links.md b/community-links.md new file mode 100644 index 0000000..074d355 --- /dev/null +++ b/community-links.md @@ -0,0 +1,6 @@ +# Community Links + +## Articles + + +## Videos \ No newline at end of file diff --git a/documentation.md b/documentation.md index cfb82ae..0516e77 100644 --- a/documentation.md +++ b/documentation.md @@ -9,6 +9,7 @@ - [Introduction](/docs/{{package}}/{{version}}/introduction) - [Installation](/docs/{{package}}/{{version}}/installation) - [Demo Application](https://datatables.yajrabox.com/) + - [Community Links](/docs/{{package}}/{{version}}/community-links) - ## Tutorials - [Quick Starter](https://datatables.yajrabox.com/starter) From a86a8a972485cf732ebc2aac36c80ec3826e90ca Mon Sep 17 00:00:00 2001 From: wremon Date: Tue, 2 Oct 2018 15:09:46 +0800 Subject: [PATCH 133/264] Add article link --- community-links.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/community-links.md b/community-links.md index 074d355..b058fa6 100644 --- a/community-links.md +++ b/community-links.md @@ -1,6 +1,10 @@ # Community Links -## Articles +You may use the links below to further understand the Laravel Datatables. + +## Articles +- [Laravel Datatables Tutorial With Example](https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/) + ## Videos \ No newline at end of file From c34c25f4a6fd3401795ed41687dce4795e650674 Mon Sep 17 00:00:00 2001 From: wremon Date: Tue, 2 Oct 2018 15:12:34 +0800 Subject: [PATCH 134/264] Add video link --- community-links.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/community-links.md b/community-links.md index b058fa6..c4efb73 100644 --- a/community-links.md +++ b/community-links.md @@ -7,4 +7,5 @@ You may use the links below to further understand the Laravel Datatables. - [Laravel Datatables Tutorial With Example](https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/) -## Videos \ No newline at end of file +## Videos +- [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) \ No newline at end of file From 36d09f14e46d7a3f1c3d3b759c6acc227537071c Mon Sep 17 00:00:00 2001 From: wremon Date: Tue, 2 Oct 2018 15:23:36 +0800 Subject: [PATCH 135/264] Fix page --- export-column.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/export-column.md b/export-column.md index 8fddc50..aad2f09 100644 --- a/export-column.md +++ b/export-column.md @@ -1,12 +1,12 @@ -# Export Column +# Export Columns You can export a column customised header if manually set. - -## Export Column + +## Export Columns ```php - protected $exportColumns = [ - ['data' => 'email', 'title' => 'Registered Email], - ]; +protected $exportColumns = [ + ['data' => 'email', 'title' => 'Registered Email'], +]; ``` \ No newline at end of file From e85ed4cdc95d74d5f547836a01a5288e88c4e509 Mon Sep 17 00:00:00 2001 From: Jeff Idago Date: Tue, 2 Oct 2018 16:05:05 +0800 Subject: [PATCH 136/264] Fix row editing header. --- documentation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation.md b/documentation.md index a40c6de..43343c1 100644 --- a/documentation.md +++ b/documentation.md @@ -40,8 +40,8 @@ - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) - [Export Columns](/docs/{{package}}/{{version}}/export-columns) - [Print Columns](/docs/{{package}}/{{version}}/print-columns) - -- Row Editing + +- ## Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) - [Row ID](/docs/{{package}}/{{version}}/row-options#row-id) - [Row Class](/docs/{{package}}/{{version}}/row-options#row-class) From 8e51836d5ac7fb25e048f2ca0304d50484b8326c Mon Sep 17 00:00:00 2001 From: Jeff Idago Date: Tue, 2 Oct 2018 16:10:22 +0800 Subject: [PATCH 137/264] Add docs for export column. --- export-column.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/export-column.md b/export-column.md index aad2f09..0295ad8 100644 --- a/export-column.md +++ b/export-column.md @@ -2,11 +2,22 @@ You can export a column customised header if manually set. + +## Export Columns with Custom Title + +```php +protected $exportColumns = [ + ['data' => 'name', 'title' => 'Name'], + ['data' => 'email', 'title' => 'Registered Email'], +]; +``` + ## Export Columns ```php protected $exportColumns = [ - ['data' => 'email', 'title' => 'Registered Email'], + 'name', + 'email', ]; ``` \ No newline at end of file From 9a47f31e88cdcb2ab025144b6b2cf36e9bdf00e6 Mon Sep 17 00:00:00 2001 From: Jeff Idago Date: Tue, 2 Oct 2018 16:16:09 +0800 Subject: [PATCH 138/264] Add docs for print column. --- print-column.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/print-column.md b/print-column.md index 0b0088f..5988404 100644 --- a/print-column.md +++ b/print-column.md @@ -2,11 +2,22 @@ You can print a column customised header if manually set. - -## Print Column + +## Print Columns with Custom Title ```php - protected $printColumns = [ - ['data' => 'email', 'title' => 'Registered Email], - ]; +protected $printColumns = [ + ['data' => 'name', 'title' => 'Name'], + ['data' => 'email', 'title' => 'Registered Email'], +]; +``` + + +## Print Columns + +```php +protected $printColumns = [ + 'name', + 'email', +]; ``` \ No newline at end of file From 440efc292091a0928350b17b74022fbb4c2ce2c9 Mon Sep 17 00:00:00 2001 From: Jeff Idago Date: Tue, 2 Oct 2018 16:28:36 +0800 Subject: [PATCH 139/264] Add video reference link. --- community-links.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/community-links.md b/community-links.md index c4efb73..19263e7 100644 --- a/community-links.md +++ b/community-links.md @@ -8,4 +8,5 @@ You may use the links below to further understand the Laravel Datatables. ## Videos -- [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) \ No newline at end of file +- [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) +- [Laravel 5x Datatable Serverside Processing](https://www.youtube.com/watch?v=m_c6DIlvGSw) \ No newline at end of file From 98865682eb09838d325dfecfb85878279e8f72e3 Mon Sep 17 00:00:00 2001 From: Jeff Idago Date: Tue, 2 Oct 2018 16:32:26 +0800 Subject: [PATCH 140/264] Add article reference link. --- community-links.md | 1 + 1 file changed, 1 insertion(+) diff --git a/community-links.md b/community-links.md index c4efb73..1107509 100644 --- a/community-links.md +++ b/community-links.md @@ -5,6 +5,7 @@ You may use the links below to further understand the Laravel Datatables. ## Articles - [Laravel Datatables Tutorial With Example](https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/) +- [How to implement DataTables server-side in laravel](https://medium.com/justlaravel/how-to-implement-datatables-server-side-in-laravel-bcacf8472d70) ## Videos From 48ebca8194116d72136228cdbec7049c3e8cb32a Mon Sep 17 00:00:00 2001 From: iman Date: Tue, 2 Oct 2018 16:44:10 +0800 Subject: [PATCH 141/264] removed link, package was not used --- community-links.md | 1 - 1 file changed, 1 deletion(-) diff --git a/community-links.md b/community-links.md index 19263e7..e7fa5e8 100644 --- a/community-links.md +++ b/community-links.md @@ -9,4 +9,3 @@ You may use the links below to further understand the Laravel Datatables. ## Videos - [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) -- [Laravel 5x Datatable Serverside Processing](https://www.youtube.com/watch?v=m_c6DIlvGSw) \ No newline at end of file From 17c133b97a8462bbbccc5f034ce1849f846f1e23 Mon Sep 17 00:00:00 2001 From: iman Date: Tue, 2 Oct 2018 17:18:25 +0800 Subject: [PATCH 142/264] Added useful video link how to use Laravel 5.4 datatables (yajra v.7.0) --- community-links.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/community-links.md b/community-links.md index 2b37dad..11f5ca4 100644 --- a/community-links.md +++ b/community-links.md @@ -10,3 +10,5 @@ You may use the links below to further understand the Laravel Datatables. ## Videos - [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) + +- [Laravel 5.4 - how to use laravel datatables (yajra v.7.0)](https://www.youtube.com/watch?v=WKS6kO9zJQI) From 616620610549748f7c588d334c59e78dd843e885 Mon Sep 17 00:00:00 2001 From: iman Date: Tue, 2 Oct 2018 17:26:36 +0800 Subject: [PATCH 143/264] Added another video tutorial on how to use Yajra Laravel DataTables --- community-links.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/community-links.md b/community-links.md index 2b37dad..5cdc3f2 100644 --- a/community-links.md +++ b/community-links.md @@ -10,3 +10,5 @@ You may use the links below to further understand the Laravel Datatables. ## Videos - [Datatables in Laravel: Default and AJAX (Demo Project)](https://www.youtube.com/watch?v=1wgLY-V69MM) +- [DataTables - Server-side Processing in Laravel using Yajra](https://www.youtube.com/watch?v=zwz_cMvASCo) + From 8261d4ac4fea118738e6fd52e5c14c6207bd0c57 Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Tue, 30 Oct 2018 16:07:56 +0800 Subject: [PATCH 144/264] Create docs for only column response. --- documentation.md | 1 + response-only.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 response-only.md diff --git a/documentation.md b/documentation.md index 43343c1..e216744 100644 --- a/documentation.md +++ b/documentation.md @@ -31,6 +31,7 @@ - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) + - [Only Columns](/docs/{{package}}/{{version}}/response-only) - ## Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) diff --git a/response-only.md b/response-only.md new file mode 100644 index 0000000..972ee1c --- /dev/null +++ b/response-only.md @@ -0,0 +1,33 @@ +# Only Response + +Get only selected columns in response. + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->only(['id','name']) + ->toJson(); +}); +``` + + +## Example Response + +```json +{ + "draw": 2, + "recordsTotal": 10, + "recordsFiltered": 2, + "data": [{ + "id": 476, + "name": "Esmeralda Kulas" + }, { + "id": 6, + "name": "Zachery Muller" + }] +} +``` From 64dc53bdbf3c5c3be37fbb025a4805db84cdaf17 Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Tue, 30 Oct 2018 16:17:12 +0800 Subject: [PATCH 145/264] Create DataTables response using laravel model resource. --- response-resource.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 response-resource.md diff --git a/response-resource.md b/response-resource.md new file mode 100644 index 0000000..19eeb14 --- /dev/null +++ b/response-resource.md @@ -0,0 +1,41 @@ +# Resource Response + +DataTables response using laravel model resource. + +```php +use DataTables; + +$users = App\User::paginate(10); + +$resource = App\Http\Resources\UserResource::collection($users); + +return DataTables::of($resource)->toJson(); +``` + + +## Example Response + +```json +{ + "draw": 10, + "recordsTotal": 10, + "recordsFiltered": 10, + "data": [{ + "id": 476, + "name": "Esmeralda Kulas", + "email": "abbott.cali@heaney.info", + "created_at": "2016-07-31 23:26:14", + "updated_at": "2016-07-31 23:26:14", + "deleted_at": null, + "superior_id": 0 + }, { + "id": 6, + "name": "Zachery Muller", + "email": "abdullah.koelpin@yahoo.com", + "created_at": "2016-07-31 23:25:43", + "updated_at": "2016-07-31 23:25:43", + "deleted_at": null, + "superior_id": 1 + }, ...] +} +``` From 01b02b55db8755f5d52ec7e986add734f8ca2f8b Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Tue, 30 Oct 2018 16:19:31 +0800 Subject: [PATCH 146/264] Add response resource link. --- documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.md b/documentation.md index e216744..8ae50d5 100644 --- a/documentation.md +++ b/documentation.md @@ -32,6 +32,7 @@ - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) - [Only Columns](/docs/{{package}}/{{version}}/response-only) + - [Response Resource](/docs/{{package}}/{{version}}/response-resource) - ## Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) From 908a44be1f8f361ab3df4762dbbd06d1511e36cd Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Tue, 30 Oct 2018 16:29:38 +0800 Subject: [PATCH 147/264] Add mutated / hidden columns. --- add-columns.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 add-columns.md diff --git a/add-columns.md b/add-columns.md new file mode 100644 index 0000000..672ea15 --- /dev/null +++ b/add-columns.md @@ -0,0 +1,52 @@ +# Add Columns + +Add mutated / hidden columns. + + +## Add hidden model columns + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->addColumns(['foo','bar','buzz'=>"red"]) + ->toJson(); +}); +``` + + +## Example Response + +```json +{ + "draw": 2, + "recordsTotal": 10, + "recordsFiltered": 3, + "data": [{ + "id": 476, + "name": "Esmeralda Kulas", + "email": "abbott.cali@heaney.info", + "created_at": "2016-07-31 23:26:14", + "updated_at": "2016-07-31 23:26:14", + "deleted_at": null, + "superior_id": 0, + "foo":"value", + "bar":"value", + "buzz":"red" + }, { + "id": 6, + "name": "Zachery Muller", + "email": "abdullah.koelpin@yahoo.com", + "created_at": "2016-07-31 23:25:43", + "updated_at": "2016-07-31 23:25:43", + "deleted_at": null, + "superior_id": 1, + "foo":"value", + "bar":"value", + "buzz":"red" + }] +} +``` \ No newline at end of file From 4bb2f719b85bd910cb96bc75fe7cea5ab8c7b56f Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Tue, 30 Oct 2018 16:31:54 +0800 Subject: [PATCH 148/264] Add column links. --- documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.md b/documentation.md index 43343c1..4b4a70d 100644 --- a/documentation.md +++ b/documentation.md @@ -34,6 +34,7 @@ - ## Column Editing - [Add Column](/docs/{{package}}/{{version}}/add-column) + - [Add Columns](/docs/{{package}}/{{version}}/add-columns) - [Edit Column](/docs/{{package}}/{{version}}/edit-column) - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) From d4046e94cce2906eaa0878eef849bdc93da6985d Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:14:03 +0800 Subject: [PATCH 149/264] Add html builder postAjax docs. --- html-builder-post-ajax.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 html-builder-post-ajax.md diff --git a/html-builder-post-ajax.md b/html-builder-post-ajax.md new file mode 100644 index 0000000..ec672d7 --- /dev/null +++ b/html-builder-post-ajax.md @@ -0,0 +1,35 @@ +# Html Builder Post Ajax + +Use post method to submit the dataTables ajax request. + +See [datatables.net](https://datatables.net/) official documentation for [`ajax option`](https://datatables.net/reference/option/ajax) for details. + +**Syntax** +```php +$builder->postAjax($attributes); +``` + +## Post Ajax Parameter +Ajax parameter (`$attributes`) can either be a string or an array. + +**String Attributes** + +When the attribute passed is a `string`. The builder will treat this as the `URL` where we fetch our data. + +```php +$builder->postAjax(route('users.data')); +``` + +> {tip} Setting ajax to `null` or `empty string` will use the current url where DataTables was used. + +**Array Attributes** + +Attributes are the same with the `ajax()` method request valid parameters. + +```php +$builder->postAjax([ + 'url' => route('users.data'), +]) +``` + + From 4d1d7f5476eb61dc7854ff2028cd6c0fcefcd301 Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:15:18 +0800 Subject: [PATCH 150/264] Add postAjax doc link. --- documentation.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation.md b/documentation.md index 43343c1..e612bcd 100644 --- a/documentation.md +++ b/documentation.md @@ -80,6 +80,7 @@ - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) + - [Post Ajax](/docs/{{package}}/{{version}}/html-builder-post-ajax) - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) @@ -106,4 +107,4 @@ - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) - [Usage](/docs/{{package}}/{{version}}/editor-usage) - [Tutorial](/docs/{{package}}/{{version}}/editor-tutorial) - - [Github](https://github.com/yajra/laravel-datatables-editor) \ No newline at end of file + - [Github](https://github.com/yajra/laravel-datatables-editor) From 9da07ab3f0f6d58c08d47208fbe56503267bfa6d Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:19:15 +0800 Subject: [PATCH 151/264] Fix DT_RowIndex name. --- html-builder-index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html-builder-index.md b/html-builder-index.md index 9179154..79ecaaa 100644 --- a/html-builder-index.md +++ b/html-builder-index.md @@ -7,8 +7,8 @@ The default attributes of index column are: ```php [ 'defaultContent' => '', - 'data' => 'DT_Row_Index', - 'name' => 'DT_Row_Index', + 'data' => 'DT_RowIndex', + 'name' => 'DT_RowIndex', 'title' => '', 'render' => null, 'orderable' => false, From d653a8203da4530abd45968079488ef1cd5cf50e Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 13 Nov 2018 16:56:44 +0800 Subject: [PATCH 152/264] Fix index column name. https://github.com/yajra/laravel-datatables/pull/1882 --- general-settings.md | 2 +- index-column.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/general-settings.md b/general-settings.md index cbf7493..358bb25 100644 --- a/general-settings.md +++ b/general-settings.md @@ -37,7 +37,7 @@ The sql generated will be like `column LIKE "%k%e%y%w%o%r%d%"` when set to `true DataTables internal index id response column name. ```php -'index_column' => 'DT_Row_Index', +'index_column' => 'DT_RowIndex', ``` diff --git a/index-column.md b/index-column.md index 8376046..a962ef9 100644 --- a/index-column.md +++ b/index-column.md @@ -16,4 +16,4 @@ Route::get('user-data', function() { ``` Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. -The default index column name is `DT_Row_Index` +The default index column name is `DT_RowIndex` From 3e7ab8731525030846fdf0c3776a037f24482de4 Mon Sep 17 00:00:00 2001 From: Igor K Date: Thu, 15 Nov 2018 14:42:46 +0200 Subject: [PATCH 153/264] Updated docs due to changes in yajra/laravel-datatables-fractal here's the [PR](https://github.com/yajra/laravel-datatables-fractal/pull/17) itself --- response-fractal.md | 62 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/response-fractal.md b/response-fractal.md index 5ecef13..f9d04e0 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -1,22 +1,70 @@ # Response using Transformer +You'll need to install [laravel-datatables-fractal package](https://github.com/yajra/laravel-datatables-fractal) if you haven't already. + When using tranformer, all response manipulations must be done via transformer. Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, etc... should be avoided when using fractal. +## Closure + +You can pass a closure wich will receive an item of the result collection and should return an array + ```php use DataTables; -use App\Transformers\UserTransformer; +use App\User; + +Route::get('user-data', function() { + $model = User::query(); + + return DataTables::eloquent($model) + ->setTransformer(function($item){ + return [ + 'id' => (int) $user->id, + 'name' => $user->name, + 'email' => $user->email, + 'created_at' => (string) $user->created_at, + 'updated_at' => (string) $user->updated_at, + ]; + }) + ->toJson(); +}); +``` + +Thus you can make use of Laravel API Resource + +```php +use DataTables; +use App\User; +use App\Http\Resources\UserResource; Route::get('user-data', function() { - $model = App\User::query(); + $model = User::query(); - return DataTables::eloquent($model) - ->setTransformer(new UserTransformer) - ->toJson(); + return DataTables::eloquent($model) + ->setTransformer(function($item){ + return UserResource::make($item)->resolve(); + }) + ->toJson(); }); ``` -## Creating Transformer + +## Transformer + +You can use Transformer class + +```php +use DataTables; +use App\Transformers\UserTransformer; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->setTransformer(new UserTransformer) + ->toJson(); +}); +``` ### Manual Way @@ -163,4 +211,4 @@ class UserTransformer extends TransformerAbstract return $this->collection($user->posts, new PostTransformer); } } -``` \ No newline at end of file +``` From 846c35eebcb975d4dd0e91946f3ff27a5822ceb3 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 16 Nov 2018 09:32:24 +0800 Subject: [PATCH 154/264] Typo fixes. --- response-fractal.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/response-fractal.md b/response-fractal.md index f9d04e0..3e67768 100644 --- a/response-fractal.md +++ b/response-fractal.md @@ -7,7 +7,7 @@ Thus `addColumn`, `editColumn`, `removeColumn`, `setRowAttr`, `setClassAttr`, et ## Closure -You can pass a closure wich will receive an item of the result collection and should return an array +You can pass a closure which will receive an item of the result collection and should return an array. ```php use DataTables; @@ -30,7 +30,7 @@ Route::get('user-data', function() { }); ``` -Thus you can make use of Laravel API Resource +Thus you can make use of Laravel API Resource. ```php use DataTables; @@ -51,7 +51,7 @@ Route::get('user-data', function() { ## Transformer -You can use Transformer class +You can use Transformer class. ```php use DataTables; From d642bbaa3502e23a722e8a7275cb8d41d573d15a Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 20 Nov 2018 12:03:56 +0800 Subject: [PATCH 155/264] Add simple pagination docs. https://github.com/yajra/laravel-datatables/pull/1911 --- documentation.md | 1 + simple-pagination.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 simple-pagination.md diff --git a/documentation.md b/documentation.md index dfff175..1414f38 100644 --- a/documentation.md +++ b/documentation.md @@ -71,6 +71,7 @@ - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) - [Set Filtered Records](/docs/{{package}}/{{version}}/set-filtered-records) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) + - [Simple Pagination](/docs/{{package}}/{{version}}/simple-pagination) ### PLUGINS diff --git a/simple-pagination.md b/simple-pagination.md new file mode 100644 index 0000000..2910e0c --- /dev/null +++ b/simple-pagination.md @@ -0,0 +1,19 @@ +# Simple Pagination + +Simple pagination aims to improve dataTables response time by skipping the total records count query and settings its value equals to the filtered total records. + + +## Example + + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->simplePagination() + ->toJson(); +}); +``` From 355d1aca170b5b7e7d6610c0dc4f06a8dca53be7 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 20 Nov 2018 12:31:49 +0800 Subject: [PATCH 156/264] Docs for https://github.com/yajra/laravel-datatables/pull/1912 --- documentation.md | 2 +- simple-pagination.md | 19 ------------------- skip-total-records.md | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 simple-pagination.md create mode 100644 skip-total-records.md diff --git a/documentation.md b/documentation.md index 1414f38..4d61911 100644 --- a/documentation.md +++ b/documentation.md @@ -69,9 +69,9 @@ - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) - [Whitelist Columns](/docs/{{package}}/{{version}}/whitelist) - [Set Total Records](/docs/{{package}}/{{version}}/set-total-records) + - [Skip Total Records](/docs/{{package}}/{{version}}/skip-total-records) - [Set Filtered Records](/docs/{{package}}/{{version}}/set-filtered-records) - [Skip Paging](/docs/{{package}}/{{version}}/skip-paging) - - [Simple Pagination](/docs/{{package}}/{{version}}/simple-pagination) ### PLUGINS diff --git a/simple-pagination.md b/simple-pagination.md deleted file mode 100644 index 2910e0c..0000000 --- a/simple-pagination.md +++ /dev/null @@ -1,19 +0,0 @@ -# Simple Pagination - -Simple pagination aims to improve dataTables response time by skipping the total records count query and settings its value equals to the filtered total records. - - -## Example - - -```php -use DataTables; - -Route::get('user-data', function() { - $model = App\User::query(); - - return DataTables::eloquent($model) - ->simplePagination() - ->toJson(); -}); -``` diff --git a/skip-total-records.md b/skip-total-records.md new file mode 100644 index 0000000..aa00a6b --- /dev/null +++ b/skip-total-records.md @@ -0,0 +1,19 @@ +# Skip Total Records + +Skip total records aims to improve dataTables response time by skipping the total records count query and settings its value equals to the filtered total records. + + +## Example + + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->skipTotalRecords() + ->toJson(); +}); +``` From e2f0975f62371ff96bc36eda827578586fbc9642 Mon Sep 17 00:00:00 2001 From: Mathieu FERRE Date: Tue, 21 May 2019 11:29:44 +0200 Subject: [PATCH 157/264] Make hidden --- make-hidden.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 make-hidden.md diff --git a/make-hidden.md b/make-hidden.md new file mode 100644 index 0000000..bdf21e0 --- /dev/null +++ b/make-hidden.md @@ -0,0 +1,17 @@ +# Hide attributes from Json + +When you are working with Eloquent Object, you can apply the `makeHidden()` ([Laravel documentation](https://laravel.com/docs/master/eloquent-serialization#hiding-attributes-from-json)) function before converting your object toArray(). + +It can prevent overriding attributes to be compute and increase the performance of converting the object into an array. + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::with('posts.comment')->query(); + + return DataTables::eloquent($model) + ->makeHidden('posts') + ->toJson(); +}); +``` From 088f22ec1c1a2919401ce38b38cd2e6e618918ee Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 5 Jul 2019 09:37:25 +0800 Subject: [PATCH 158/264] Bump installation to v9.0 --- installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installation.md b/installation.md index b4b5216..5cab060 100644 --- a/installation.md +++ b/installation.md @@ -22,13 +22,13 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ```bash -composer require yajra/laravel-datatables-oracle:^8.0 +composer require yajra/laravel-datatables-oracle:^9.0 ``` If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. ```bash -composer require yajra/laravel-datatables:^1.0 +composer require yajra/laravel-datatables:^1.5 ``` From 64389418a8f665b3b9db7eafd8ac2f648c8e2a5e Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 5 Jul 2019 09:59:01 +0800 Subject: [PATCH 159/264] Add column class builder docs. --- documentation.md | 1 + html-builder-column-builder.md | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 html-builder-column-builder.md diff --git a/documentation.md b/documentation.md index 4d61911..32890e6 100644 --- a/documentation.md +++ b/documentation.md @@ -81,6 +81,7 @@ - [Table](/docs/{{package}}/{{version}}/html-builder-table) - [Config](/docs/{{package}}/{{version}}/html-builder-config) - [Columns](/docs/{{package}}/{{version}}/html-builder-column) + - [Column Builder](/docs/{{package}}/{{version}}/html-builder-column-builder) - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) diff --git a/html-builder-column-builder.md b/html-builder-column-builder.md new file mode 100644 index 0000000..b523cb0 --- /dev/null +++ b/html-builder-column-builder.md @@ -0,0 +1,38 @@ +# Html Builder - Column Builder + +Column Builder is a fluent class that we can use to build our columns. + + +## Upgrading Your Existing Column Definitions + +### FROM + +```php +$column = [ + 'name' => 'id', + 'data' => 'id', + 'title' => 'Id', + 'searchable' => true, + 'orderable' => true, + 'render' => 'function(){}', + 'footer' => 'Id', + 'exportable' => true, + 'printable' => true, +]; +``` + +### TO + +```php +use Yajra\DataTables\Html\Column; + +$column = Column::make('id') + ->title('Id') + ->searchable(true) + ->orderable(true) + ->render('function(){}') + ->footer('Id') + ->exportable(true) + ->printable(true); +``` + From 966ddab471e7061132b3d6566328c2fbe3d6eb98 Mon Sep 17 00:00:00 2001 From: Rogelio Jacinto Pascual Date: Sun, 14 Jul 2019 23:43:51 -0600 Subject: [PATCH 160/264] Update code samples with changes in version 1.8.0 Describe that from version 1.8.0 onwards `creating`, `created`, `updating`, `updated`, and `saved` event hooks must return the `$model` instance. Add documentation and code sample for `saved` event hook. Remove `return $data` from `deleting` and `deleted` code samples, and instead add comment on what the code may do on each case. --- editor-events.md | 53 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/editor-events.md b/editor-events.md index e830981..64d2216 100644 --- a/editor-events.md +++ b/editor-events.md @@ -13,12 +13,20 @@ Create action has the following event hooks: To use the event hook, just add the methods on your editor class. ```php -public function creating(Model $model, array $data) { - return $data; +public function creating(Model $model, array $data) +{ + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required + // to return the $model. + // In version 1.8.0+ the hook must return the $model instance: + return $model; } -public function created(Model $model, array $data) { - return $data; +public function created(Model $model, array $data) +{ + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required + // to return the $model. + // In version 1.8.0+ the hook must return the $model instance: + return $model; } ``` @@ -34,11 +42,34 @@ To use the event hook, just add the methods on your editor class. ```php public function updating(Model $model, array $data) { - return $data; + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required + // to return the $model. + // In version 1.8.0+ the hook must return the $model: + return $model; } public function updated(Model $model, array $data) { - return $data; + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required + // to return the $model. + // In version 1.8.0+ the hook must return the $model instance: + return $model; +} +``` + + +## Saved event + +In addition to create and edit events, the `saved` event hook is called after `created` and `saved`. + +To use the event hook, just add the method on your editor class: + +```php +public function saved(Model $model, array $data) +{ + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required + // to return the $model. + // In version 1.8.0+ the hook must return the $model instance: + return $model; } ``` @@ -47,17 +78,21 @@ public function updated(Model $model, array $data) { Remove action has the following event hooks: -- `deleting` event hook that is fired before deleting a new record. +- `deleting` event hook that is fired before deleting a record. - `deleted` event hook that is fired after the record was deleted. To use the event hook, just add the methods on your editor class. ```php public function deleting(Model $model, array $data) { - return $data; + // Record still exists in database. Code can be used to delete records from + // child tables that don't specify cascade deletes on the foreign key + // definition. } public function deleted(Model $model, array $data) { - return $data; + // Record no longer exists in database, but $model instance still contains + // data as it was before deleting. Any instance state mutation will be + // preserved and returned in the 'data' array of the response. } ``` From 064436f8aa6f8eff0a086f0322a860a86b7ee2a9 Mon Sep 17 00:00:00 2001 From: Rogelio Jacinto Pascual Date: Mon, 15 Jul 2019 15:41:14 -0600 Subject: [PATCH 161/264] Fix innaccuracy in hooks examples. Add PHPDoc blocks to sample code. `creating`, `updating`, and `saving` must always return `$data` array. --- editor-events.md | 127 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 111 insertions(+), 16 deletions(-) diff --git a/editor-events.md b/editor-events.md index 64d2216..446b142 100644 --- a/editor-events.md +++ b/editor-events.md @@ -13,18 +13,40 @@ Create action has the following event hooks: To use the event hook, just add the methods on your editor class. ```php +/** + * Event hook that is fired before creating a new record. + * + * @param \Illuminate\Database\Eloquent\Model $model Empty model instance. + * @param array $data Attribute values array received from Editor. + * @return array The updated attribute values array. + */ public function creating(Model $model, array $data) { - // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required - // to return the $model. - // In version 1.8.0+ the hook must return the $model instance: - return $model; + // Code can change the attribute values array before saving data to the + // database. + // Can be used to initialize values on new model. + + // Since arrays are copied when passed by value, the function must return + // the updated $data array + return $data; } +/** + * Event hook that is fired after a new record is created. + * + * @param \Illuminate\Database\Eloquent\Model $model The newly created model. + * @param array $data Attribute values array received from `creating` or + * `saving` hook. + * @return \Illuminate\Database\Eloquent\Model Since version 1.8.0 it must + * return the $model. + */ public function created(Model $model, array $data) { - // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required - // to return the $model. + // Can be used to mutate state of newly created model that is returned to + // Editor. + + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not + // required to return the $model. // In version 1.8.0+ the hook must return the $model instance: return $model; } @@ -35,20 +57,41 @@ public function created(Model $model, array $data) Edit action has the following event hooks: -- `updating` event hook that is fired before updating a new record. +- `updating` event hook that is fired before updating an existing record. - `updated` event hook that is fired after the record was updated. To use the event hook, just add the methods on your editor class. ```php +/** + * Event hook that is fired before updating an existing record. + * + * @param \Illuminate\Database\Eloquent\Model $model Model instance retrived + * retrived from database. + * @param array $data Attribute values array received from Editor. + * @return array The updated attribute values array. + */ public function updating(Model $model, array $data) { - // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required - // to return the $model. - // In version 1.8.0+ the hook must return the $model: - return $model; + // Can be used to modify the attribute values received from Editor before + // applying changes to model. + + // Since arrays are copied when passed by value, the function must return + // the updated $data array + return $data; } +/** + * Event hook that is fired after the record was updated. + * + * @param \Illuminate\Database\Eloquent\Model $model Updated model instance. + * @param array $data Attribute values array received from `updating` or + * `saving` hook. + * @return \Illuminate\Database\Eloquent\Model Since version 1.8.0 it must + * return the $model. + */ public function updated(Model $model, array $data) { + // Can be used to mutate state of updated model that is returned to Editor. + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required // to return the $model. // In version 1.8.0+ the hook must return the $model instance: @@ -56,16 +99,52 @@ public function updated(Model $model, array $data) { } ``` - -## Saved event + +## Save events -In addition to create and edit events, the `saved` event hook is called after `created` and `saved`. +In addition to create and edit events, the following save event hooks are available: + +- `saving` event hook that is fired after `creating` and `updating` events, but + before the model is saved to the database. +- `saved` event hook that is fired after `created` and `updated` events. To use the event hook, just add the method on your editor class: ```php +/** + * Event hook that is fired after `creating` and `updating` hooks, but before + * the model is saved to the database. + * + * @param \Illuminate\Database\Eloquent\Model $model Empty model when creating; + * Original model when updating. + * @param array $data Attribute values array received from `creating` or + * `updating` event hook. + * @return array The updated attribute values array. + */ +public function saving(Model $model, array $data) +{ + // The event hook can be used to modify the $data array that is used to + // create or update the record. + + // Since arrays are copied when passed by value, the function must return + // the updated $data array + return $data; +} + +/** + * Event hook that is fired after `created` and `updated` events. + * + * @param \Illuminate\Database\Eloquent\Model $model The new model when + * creating; the updated model when updating. + * @param array $data Attribute values array received from `creating`, + * `updating`, or `saving`. + * @return \Illuminate\Database\Eloquent\Model Since version 1.8.0 it must + * return the $model. + */ public function saved(Model $model, array $data) { + // Can be used to mutate state of updated model that is returned to Editor. + // Prior to version 1.8.0 of Laravel DataTables Editor the hook was not required // to return the $model. // In version 1.8.0+ the hook must return the $model instance: @@ -84,15 +163,31 @@ Remove action has the following event hooks: To use the event hook, just add the methods on your editor class. ```php +/** + * Event hook that is fired before deleting an existing record. + * + * @param \Illuminate\Database\Eloquent\Model $model The original model + * retrieved from database. + * @param array $data Attribute values array received from Editor. + * @return void + */ public function deleting(Model $model, array $data) { // Record still exists in database. Code can be used to delete records from // child tables that don't specify cascade deletes on the foreign key // definition. } +/** + * Event hook that is fired after deleting the record from database. + * + * @param \Illuminate\Database\Eloquent\Model $model The original model + * retrieved from database. + * @param array $data Attribute values array received from Editor. + * @return void + */ public function deleted(Model $model, array $data) { // Record no longer exists in database, but $model instance still contains - // data as it was before deleting. Any instance state mutation will be - // preserved and returned in the 'data' array of the response. + // data as it was before deleting. Any changes to the $model instance will + // be returned to Editor. } ``` From 377f5a556c8cec9803b1318463eee673bfc57303 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Sat, 31 Aug 2019 09:00:39 +0800 Subject: [PATCH 162/264] Add startsWithSearch docs. --- documentation.md | 1 + starts-with-search.md | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 starts-with-search.md diff --git a/documentation.md b/documentation.md index 32890e6..c206ebf 100644 --- a/documentation.md +++ b/documentation.md @@ -56,6 +56,7 @@ - [Filter Column](/docs/{{package}}/{{version}}/filter-column) - [Regex Search](/docs/{{package}}/{{version}}/regex) - [Smart Search](/docs/{{package}}/{{version}}/smart-search) + - [Starts With Search](/docs/{{package}}/{{version}}/starts-with-search) - [Relationships](/docs/{{package}}/{{version}}/relationships) - ## Sorting/Ordering diff --git a/starts-with-search.md b/starts-with-search.md new file mode 100644 index 0000000..b44c25b --- /dev/null +++ b/starts-with-search.md @@ -0,0 +1,11 @@ +# Starts With Search + +Starts with search feature allows the package to search our tables with records that starts with the given keyword. +To enable the feature, just chain `->startsWithSearch()` on your instance. + +```php +return datatables() + ->eloquent($model) + ->startsWithSearch() + ->toJson(); +``` From 47448584297e88002130e086506d773744e1b1c2 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 10 Sep 2019 14:19:51 +0800 Subject: [PATCH 163/264] Add upload docs. --- editor-events.md | 22 ++++++++++++++++++++++ editor-rules.md | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/editor-events.md b/editor-events.md index 446b142..cb338a5 100644 --- a/editor-events.md +++ b/editor-events.md @@ -191,3 +191,25 @@ public function deleted(Model $model, array $data) { // be returned to Editor. } ``` + + +## Upload Events + +Upload action has the following event hooks: + +- `uploaded` event hook that is fired after a file was uploaded. + +To use the event hook, just add the methods on your editor class. + +```php +/** + * Event hook that is fired after upload a file. + * + * @param string $id The auto-generated file id from filesystem. + * @return string + */ +public function uploaded($id) { + // return the file id. + return $id; +} +``` diff --git a/editor-rules.md b/editor-rules.md index e467aa5..b5437e8 100644 --- a/editor-rules.md +++ b/editor-rules.md @@ -40,3 +40,17 @@ public function removeRules(Model $model) { return []; } ``` + + +## Upload Rules + +This are the rules that will be used when validating an upload action. + +```php +public function uploadRules() { + return [ + 'avatar' => 'required|image', + 'resume' => 'required|mimes:pdf', + ]; +} +``` From a64588ec32b55f3e0c3c10e664e5ebfdf7a2c297 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Tue, 10 Sep 2019 14:21:24 +0800 Subject: [PATCH 164/264] Typo. --- editor-events.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor-events.md b/editor-events.md index cb338a5..9eb2b4a 100644 --- a/editor-events.md +++ b/editor-events.md @@ -203,7 +203,7 @@ To use the event hook, just add the methods on your editor class. ```php /** - * Event hook that is fired after upload a file. + * Event hook that is fired after uploading a file. * * @param string $id The auto-generated file id from filesystem. * @return string From 2016f10b70da92a77e46284b8414f71f3315850c Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Wed, 2 Oct 2019 13:38:09 +0800 Subject: [PATCH 165/264] Fix typo for config.md --- buttons/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons/config.md b/buttons/config.md index 9887c42..2f41911 100644 --- a/buttons/config.md +++ b/buttons/config.md @@ -24,7 +24,7 @@ This directory is appended on default Laravel namespace. **Export filename:** ```users_(timestamp)``` ### Model Option -This is the base namespace/directory where your model's are located. +This is the base namespace/directory where your models are located. This directory is appended on default Laravel namespace. **Usage:** ```php artisan datatables:make Post --model``` **Output:** ```App\DataTables\PostDataTable``` From a08f94981c78ef43a1238acca47c45e2db897593 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Wed, 2 Oct 2019 13:58:01 +0800 Subject: [PATCH 166/264] Add example of orderColumn using closure --- order-column.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/order-column.md b/order-column.md index 711483d..4bcb1c7 100644 --- a/order-column.md +++ b/order-column.md @@ -17,3 +17,16 @@ Route::get('user-data', function() { ->toJson(); }); ``` + +Here is another example of orderColumn using closure. +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->orderColumn('name', function($query, $order) { + $query->orderBy('status', $order); + }); +}); From 52f150652279a5114937679d8d578d1ea7a1d6e5 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Wed, 2 Oct 2019 14:56:19 +0800 Subject: [PATCH 167/264] edit example order column --- order-column.md | 1 + 1 file changed, 1 insertion(+) diff --git a/order-column.md b/order-column.md index 4bcb1c7..91055c9 100644 --- a/order-column.md +++ b/order-column.md @@ -30,3 +30,4 @@ Route::get('user-data', function() { $query->orderBy('status', $order); }); }); +``` \ No newline at end of file From 937edb916cf96cced267868c8065f32f0eef939a Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Wed, 2 Oct 2019 15:16:05 +0800 Subject: [PATCH 168/264] Add space and CS fix --- order-column.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/order-column.md b/order-column.md index 91055c9..0b78517 100644 --- a/order-column.md +++ b/order-column.md @@ -19,15 +19,16 @@ Route::get('user-data', function() { ``` Here is another example of orderColumn using closure. + ```php use DataTables; -Route::get('user-data', function() { - $model = App\User::query(); +Route::get('user-data', function () { + $model = App\User::query(); - return DataTables::eloquent($model) - ->orderColumn('name', function($query, $order) { - $query->orderBy('status', $order); + return DataTables::eloquent($model) + ->orderColumn('name', function ($query, $order) { + $query->orderBy('status', $order); }); }); ``` \ No newline at end of file From 94745b99fe381788ef53dec13e806762d0b83d88 Mon Sep 17 00:00:00 2001 From: Jerome Sarmiento Date: Thu, 3 Oct 2019 11:04:36 +0800 Subject: [PATCH 169/264] revert buttons config --- buttons-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-config.md b/buttons-config.md index 9efe06d..5b4260d 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -24,7 +24,7 @@ This directory is appended on default Laravel namespace. **Export filename:** ```users_(timestamp)``` ### Model Option -This is the base namespace/directory where your models are located. +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``` From 69ae8732d6711aa8bf1e12f5b4282999657b60ab Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 Nov 2019 10:35:50 +0800 Subject: [PATCH 170/264] Add new Laravel 6 quick starter doc. --- documentation.md | 2 +- quick-starter.md | 214 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+), 1 deletion(-) create mode 100644 quick-starter.md diff --git a/documentation.md b/documentation.md index c206ebf..cf92ae2 100644 --- a/documentation.md +++ b/documentation.md @@ -12,7 +12,7 @@ - [Community Links](/docs/{{package}}/{{version}}/community-links) - ## Tutorials - - [Quick Starter](https://datatables.yajrabox.com/starter) + - [Quick Starter](/docs/{{package}}/{{version}}/quick-starter) - [Service Implementation](https://datatables.yajrabox.com/service) - ## Configuration diff --git a/quick-starter.md b/quick-starter.md new file mode 100644 index 0000000..f720a7b --- /dev/null +++ b/quick-starter.md @@ -0,0 +1,214 @@ +# Laravel 6 and DataTables Quick Starter + +## Create new project + +``` +laravel new {project name} +cd {project name} +cp .env.example .env +php artisan key:generate +``` + +## Setup database and ENV configuration + +Create a new database and update `.env` file and set the datbase credentials. + +## Install package and publish assets + +``` +composer require yajra/laravel-datatables +php artisan vendor:publish --tag=datatables-buttons + +``` + +## Setup Laravel UI + +``` +composer require laravel/ui --dev +php artisan ui bootstrap --auth +``` + +## Install Datatables.net assets + +``` +yarn add datatables.net-bs4 datatables.net-buttons-bs4 +``` + +## Register datatables.net assets in bootstrap.js + +Edit `resources/js/bootstrap.js` and add the following: + + require('bootstrap'); + require('datatables.net-bs4'); + require('datatables.net-buttons-bs4'); + require('datatables.net-select-bs4'); + +## Compile assets + +``` +yarn dev / watch / prod +``` + +## Create controller and DataTable class + +``` +php artisan make:controller UsersController +php artisan datatables:make Users +``` + +### UsersController + +```php +namespace App\Http\Controllers; + +use App\DataTables\UsersDataTable; + +class UsersController extends Controller +{ + public function index(UsersDataTable $dataTable) + { + return $dataTable->render('users.index'); + } +} +``` + +### UsersDataTable + +```php +namespace App\DataTables; + +use App\User; +use Yajra\DataTables\Html\Button; +use Yajra\DataTables\Html\Column; +use Yajra\DataTables\Html\Editor\Editor; +use Yajra\DataTables\Html\Editor\Fields; +use Yajra\DataTables\Services\DataTable; + +class UsersDataTable extends DataTable +{ + /** + * Build DataTable class. + * + * @param mixed $query Results from query() method. + * @return \Yajra\DataTables\DataTableAbstract + */ + public function dataTable($query) + { + return datatables() + ->eloquent($query) + ->addColumn('action', 'users.action'); + } + + /** + * Get query source of dataTable. + * + * @param \App\User $model + * @return \Illuminate\Database\Eloquent\Builder + */ + public function query(User $model) + { + return $model->newQuery(); + } + + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\DataTables\Html\Builder + */ + public function html() + { + return $this->builder() + ->setTableId('users-table') + ->columns($this->getColumns()) + ->minifiedAjax() + ->dom('Bfrtip') + ->orderBy(1) + ->buttons( + Button::make('create'), + Button::make('export'), + Button::make('print'), + Button::make('reset'), + Button::make('reload') + ); + } + + /** + * Get columns. + * + * @return array + */ + protected function getColumns() + { + return [ + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + Column::make('id'), + Column::make('name'), + Column::make('email'), + Column::make('created_at'), + Column::make('updated_at'), + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename() + { + return 'Users_' . date('YmdHis'); + } +} +``` + +## Update app layout + +Add scripts before the body end tag of `resources/views/layouts/app.blade.php` + +``` + + + @stack('scripts') +``` + +## Create users index file + +Create new file: `resources/views/users/index.blade.php`. + +```php +@extends('layouts.app') + +@section('content') + {{$dataTable->table()}} +@endsection + +@push('scripts') + {{$dataTable->scripts()}} +@endpush +``` + +## Register users route + +Update `routes/web.php`. + +```php +Route::get('/users', 'UsersController@index')->name('users.index'); +``` + +## Create dummy data using tinker + +```php +php artisan tinker + +Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman +>>> factory('App\User', 100)->create() +``` + +## Access Users DataTables + +http://{project name}.test/users + From cbffccfdc3601c983a8741ec7b0e880da086caa4 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 Nov 2019 10:43:20 +0800 Subject: [PATCH 171/264] Remove select plugin. --- quick-starter.md | 1 - 1 file changed, 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index f720a7b..9b7f2e2 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -41,7 +41,6 @@ Edit `resources/js/bootstrap.js` and add the following: require('bootstrap'); require('datatables.net-bs4'); require('datatables.net-buttons-bs4'); - require('datatables.net-select-bs4'); ## Compile assets From 41acc7674d606a8f2a48bd0ac599e1ec4423080b Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 Nov 2019 10:44:44 +0800 Subject: [PATCH 172/264] Update title. --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 9b7f2e2..6386b44 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,4 +1,4 @@ -# Laravel 6 and DataTables Quick Starter +# Laravel DataTables Quick Starter ## Create new project From d383318c28eee37c59295a18b02b4c06283edf6f Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 Nov 2019 10:45:19 +0800 Subject: [PATCH 173/264] Set project name. --- quick-starter.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 6386b44..80ab872 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -3,8 +3,8 @@ ## Create new project ``` -laravel new {project name} -cd {project name} +laravel new datatables +cd datatables cp .env.example .env php artisan key:generate ``` @@ -209,5 +209,5 @@ Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman ## Access Users DataTables -http://{project name}.test/users +http://datatables.test/users From 99e34900f5dbbd2cbffe96a7fc22588fe967ecfd Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 Nov 2019 10:49:45 +0800 Subject: [PATCH 174/264] Shorten title. --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 80ab872..35ed910 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,4 +1,4 @@ -# Laravel DataTables Quick Starter +# DataTables Quick Starter ## Create new project From c85df2d02f3cd1de16d1586b391a147828fff8f9 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Mon, 11 Nov 2019 12:00:44 +0800 Subject: [PATCH 175/264] Update editor tutorial using yarn / npm. --- editor-tutorial.md | 377 ++++++++++----------------------------------- 1 file changed, 82 insertions(+), 295 deletions(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index 2cf0fcb..389b804 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -3,346 +3,133 @@ Before we begin, please be reminded that the Editor library that we are going to use here requires a paid license. See [DataTables Editor](https://editor.datatables.net/purchase/index) for details. -## Create a new laravel app +## Pre-requisites -Using [laravel installer](https://laravel.com/docs/5.5/installation), run the command below using terminal. +This tutorial requires https://yajrabox.com/docs/laravel-datatables/master/quick-starter. -```bash -laravel new editor -``` +## Install DataTables Editor assets. -Once installed, lets configure our application and use `sqlite` as our database by updating `DB_CONNECTION=sqlite`. -We also need to remove the following lines as it is not needed for sqlite. + yarn add datatables.net-editor datatables.net-editor-bs4 -```php -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=homestead -DB_USERNAME=homestead -DB_PASSWORD=secret -``` +## Editor License -Next, create our database and run the migration. We will then seed some users using tinker. - -```bash -cd editor -touch database/database.sqlite -php artisan migrate -php artisan tinker ->>> factory(App\User::class, 20)->create(); -``` +Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project folder. -## Install DataTables Editor library. +## Register postinstall script to package.json -In this step, we will only need to install `yajra/laravel-datatables-editor`. + "scripts": { + "postinstall": "node ./node_modules/datatables.net-editor/install.js ./Editor.zip", + "dev": "npm run development", + ..... + }, -```bash -composer require yajra/laravel-datatables-editor -``` +## Register editor script on `resources/js/bootstrap.js` -## Create Controllers, DataTables and Editor classes. + try { + window.Popper = require('popper.js').default; + window.$ = window.jQuery = require('jquery'); -```php -php artisan make:controller UsersController -php artisan datatables:make Users -php artisan datatables:editor Users -``` + require('bootstrap'); + require('datatables.net-bs4'); + require('datatables.net-buttons-bs4'); + require('datatables.net-editor-bs4'); + } catch (e) {} -These commands will generate the following files: -- app\Http\Controllers\UsersController.php -- app\DataTables\UsersDataTable.php -- app\DataTables\UsersDataTablesEditor.php -## Setup Controller +## Recompile assets. -We will only need `index` and `store` method for our controller. But before that, lets register our route first on `routes\web.php` + yarn + yarn watch / dev / prod -```php -Route::resource('users', 'UsersController'); -``` -Will now add the methods on our controller. +## Update UsersDataTable and register the Editor buttons. -```php - Note: CREATE button is in conflict with `buttons.server-side.js`. You need to remove the create button or rename it to something else like `add` button. -namespace App\Http\Controllers; + DataTable.ext.buttons.add = { + className: 'buttons-add', -use Illuminate\Http\Request; -use App\DataTables\UsersDataTable; -use App\DataTables\UsersDataTablesEditor; + text: function (dt) { + return ' ' + dt.i18n('buttons.add', 'Create'); + }, -class UsersController extends Controller -{ - public function index(UsersDataTable $dataTable) - { - return $dataTable->render('users.index'); - } + action: function (e, dt, button, config) { + window.location = window.location.href.replace(/\/+$/, "") + '/create'; + } + }; - public function store(UsersDataTablesEditor $editor) - { - return $editor->process(request()); - } -} -``` +### UsersDataTable.php -## Setup DataTable +Create a new editor instance and add some fields for name and email. ```php -setRowId('id')->addColumn('password', ''); - } - - /** - * Get query source of dataTable. - * - * @param \App\User $model - * @return \Illuminate\Database\Eloquent\Builder - */ - public function query(User $model) - { - return $model->newQuery()->select('id', 'name', 'email'); - } - - /** - * Optional method if you want to use html builder. - * - * @return \Yajra\DataTables\Html\Builder - */ +... public function html() { return $this->builder() + ->setTableId('users-table') ->columns($this->getColumns()) ->minifiedAjax() - ->parameters([ - 'dom' => 'Bfrtip', - 'order' => [1, 'asc'], - 'select' => [ - 'style' => 'os', - 'selector' => 'td:first-child', - ], - 'buttons' => [ - ['extend' => 'create', 'editor' => 'editor'], - ['extend' => 'edit', 'editor' => 'editor'], - ['extend' => 'remove', 'editor' => 'editor'], - ] - ]); + ->dom('Bfrtip') + ->orderBy(1) + ->buttons( + Button::make('create')->editor('editor'), + Button::make('edit')->editor('editor'), + Button::make('remove')->editor('editor'), + Button::make('export'), + Button::make('print'), + Button::make('reset'), + Button::make('reload') + ) + ->editor( + Editor::make() + ->fields([ + Fields\Text::make('name'), + Fields\Text::make('email'), + Fields\Password::make('password'), + ]) + ); } +``` - /** - * Get columns. - * - * @return array - */ - protected function getColumns() - { - return [ - [ - 'data' => null, - 'defaultContent' => '', - 'className' => 'select-checkbox', - 'title' => '', - 'orderable' => false, - 'searchable' => false - ], - 'id', - 'name', - 'email', - ]; - } +## Create Editor Class to handle CRUD actions. - /** - * Get filename for export. - * - * @return string - */ - protected function filename() - { - return 'users_' . time(); - } -} +``` +php artisan datatables:editor Users ``` -## Setup Editor +## Register Editor Route -```php -name('users.store'); +``` -use App\User; -use Illuminate\Validation\Rule; -use Yajra\DataTables\DataTablesEditor; -use Illuminate\Database\Eloquent\Model; +## Update users controller -class UsersDataTablesEditor extends DataTablesEditor -{ - protected $model = User::class; - - /** - * Get create action validation rules. - * - * @return array - */ - public function createRules() - { - return [ - 'email' => 'required|email|unique:users', - 'name' => 'required', - ]; - } - - /** - * Get edit action validation rules. - * - * @param Model $model - * @return array - */ - public function editRules(Model $model) - { - return [ - 'email' => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()), - 'name' => 'sometimes|required', - ]; - } +``` +namespace App\Http\Controllers; - /** - * Get remove action validation rules. - * - * @param Model $model - * @return array - */ - public function removeRules(Model $model) - { - return []; - } +use Illuminate\Http\Request; +use App\DataTables\UsersDataTable; +use App\DataTables\UsersDataTableEditor; - /** - * Pre-create action event hook. - * - * @param Model $model - * @return array - */ - public function creating(Model $model, array $data) +class UsersController extends Controller +{ + public function index(UsersDataTable $dataTable) { - $data['password'] = bcrypt($data['password']); - - return $data; + return $dataTable->render('users.index'); } - /** - * Pre-update action event hook. - * - * @param Model $model - * @return array - */ - public function updating(Model $model, array $data) + public function store(UsersDataTableEditor $editor) { - if (empty($data['password'])) { - unset($data['password']); - } else { - $data['password'] = bcrypt($data['password']); - } - - return $data; + return $editor->process(request()); } } ``` -## Setup View - -Lets create our users admin panel view at `resources/views/users/index.blade.php`. - -```php - - - - - - - - Laravel DataTables Editor - - - - - - - - - - - - - - - - - - - - - -
- {{$dataTable->table(['id' => 'users'])}} -
- - - - -``` - -## Register and Download your trial Editor library - -You can download the library assets [here](https://editor.datatables.net/download/) once you successfully registered to DataTables. -We would only need the JS and CSS so I suggest you only download those files. -Once downloaded, copy the library to `public/plugins/editor` of your laravel public directory. - -## Run your application - -Using valet, visit your site using `http://editor.dev/users` and see the full CRUD in action. - -## Gist - -See this [gist](https://gist.github.com/yajra/38ee8d2521fa419309dfabcb667d9c2a) for the complete source code of added files. +## See your editor in action. From 68e8f2684ada73824fe57d032af289db09c0c628 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Wed, 13 Nov 2019 08:14:13 +0800 Subject: [PATCH 176/264] Include select extension. --- editor-tutorial.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index 389b804..cbf6e16 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -9,7 +9,7 @@ This tutorial requires https://yajrabox.com/docs/laravel-datatables/master/quick ## Install DataTables Editor assets. - yarn add datatables.net-editor datatables.net-editor-bs4 + yarn add datatables.net-editor-bs4 datatables.net-select-bs4 ## Editor License @@ -32,6 +32,7 @@ Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project fold require('bootstrap'); require('datatables.net-bs4'); require('datatables.net-buttons-bs4'); + require('datatables.net-select-bs4'); require('datatables.net-editor-bs4'); } catch (e) {} From 86d253622cfaef8e64053cbdcb1a1710178f6187 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Thu, 14 Nov 2019 11:37:36 +0800 Subject: [PATCH 177/264] Add missing dt styles. --- quick-starter.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 35ed910..6d152b0 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -34,7 +34,7 @@ php artisan ui bootstrap --auth yarn add datatables.net-bs4 datatables.net-buttons-bs4 ``` -## Register datatables.net assets in bootstrap.js +## Register datatables.net assets in bootstrap.js and app.scss Edit `resources/js/bootstrap.js` and add the following: @@ -42,6 +42,12 @@ Edit `resources/js/bootstrap.js` and add the following: require('datatables.net-bs4'); require('datatables.net-buttons-bs4'); +Edit `resources/scss/app.scss` and add the following: + + // DataTables + @import "~datatables.net-bs4/css/dataTables.bootstrap4.css"; + @import "~datatables.net-buttons-bs4/css/buttons.bootstrap4.css"; + ## Compile assets ``` From bc8222df5f68b9b584ffc1c17fa1bde756f016a9 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Thu, 14 Nov 2019 11:45:30 +0800 Subject: [PATCH 178/264] Add main editor script and styles. --- editor-tutorial.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index cbf6e16..ed3c6c9 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -9,7 +9,7 @@ This tutorial requires https://yajrabox.com/docs/laravel-datatables/master/quick ## Install DataTables Editor assets. - yarn add datatables.net-editor-bs4 datatables.net-select-bs4 + yarn add datatables.net-editor datatables.net-editor-bs4 datatables.net-select-bs4 ## Editor License @@ -37,6 +37,11 @@ Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project fold } catch (e) {} +## Add editor styles on `resources/scss/app.scss`. + + @import "~datatables.net-select-bs4/css/select.bootstrap4.css"; + @import "~datatables.net-editor-bs4/css/editor.bootstrap4.css"; + ## Recompile assets. yarn From 79072e0c80ae52abb7cf03b1c41324f2aabb55c4 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 15 Nov 2019 14:17:25 +0800 Subject: [PATCH 179/264] Fix sass path and add setRowId. --- editor-tutorial.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index ed3c6c9..cf453b2 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -37,7 +37,7 @@ Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project fold } catch (e) {} -## Add editor styles on `resources/scss/app.scss`. +## Add editor styles on `resources/sass/app.scss`. @import "~datatables.net-select-bs4/css/select.bootstrap4.css"; @import "~datatables.net-editor-bs4/css/editor.bootstrap4.css"; @@ -73,6 +73,20 @@ use Yajra\DataTables\Html\Editor\Editor; use Yajra\DataTables\Html\Editor\Fields; ... + /** + * Build DataTable class. + * + * @param mixed $query Results from query() method. + * @return \Yajra\DataTables\DataTableAbstract + */ + public function dataTable($query) + { + return datatables() + ->eloquent($query) + ->setRowId('id') // Set the RowID + ... + } + public function html() { return $this->builder() From 3202d0327cc73399fce71b97dfaa1d34ed8acec8 Mon Sep 17 00:00:00 2001 From: Andy Tan Date: Mon, 20 Jan 2020 11:20:47 +0800 Subject: [PATCH 180/264] Replace make(true) with toJson --- response-object.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/response-object.md b/response-object.md index 84b13b5..6c1c088 100644 --- a/response-object.md +++ b/response-object.md @@ -1,6 +1,6 @@ # Object Response -To convert the response of DataTables to an object, just pass `true` on `make` api. +To convert the response of DataTables to an object, use `toJson` api. ```php use DataTables; From fcd6b31834dd6c7bc8dfad33276b06389b54bc1c Mon Sep 17 00:00:00 2001 From: skys215 Date: Sat, 22 Feb 2020 00:14:49 +0800 Subject: [PATCH 181/264] Update html-installation.md --- html-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-installation.md b/html-installation.md index e0d0415..a1e08f6 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,7 +4,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^3.0` +`composer require yajra/laravel-datatables-html:^4.0` ## Configuration > This step is optional if you are using Laravel 5.5 From bac00f13d42bc5ea204f185f42d74382c1d13c06 Mon Sep 17 00:00:00 2001 From: skys215 Date: Sat, 22 Feb 2020 00:15:39 +0800 Subject: [PATCH 182/264] Update buttons-installation.md --- buttons-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-installation.md b/buttons-installation.md index 87e80a8..27ef960 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^3.0` +`composer require yajra/laravel-datatables-buttons:^4.0` ## Configuration > This step is optional if you are using Laravel 5.5 From dece4e9939bb71e714d5e26a683f380421932e08 Mon Sep 17 00:00:00 2001 From: "Md. Zahedul Hossain" Date: Thu, 19 Mar 2020 13:24:41 +0600 Subject: [PATCH 183/264] add note for addColumn api --- add-column.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/add-column.md b/add-column.md index 01dcaf3..92e82c0 100644 --- a/add-column.md +++ b/add-column.md @@ -2,6 +2,8 @@ You can add a custom column on your response by using `addColumn` api. +> {note} added columns are assumed to be computed columns and not part of the database. Thus, search/sort will be disabled on those columns. If you need them, use the `editColumn` api instead. + ## Add Column with Blade Syntax From 0ef23dd84ddde8e81ea309c8a0d49210fe09cef4 Mon Sep 17 00:00:00 2001 From: Oussama Date: Sun, 12 Apr 2020 00:04:51 +0200 Subject: [PATCH 184/264] Fix typo readbale => readable --- engine-query.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine-query.md b/engine-query.md index 4d2c09d..e800e53 100644 --- a/engine-query.md +++ b/engine-query.md @@ -1,7 +1,7 @@ # Query Builder Data Source You may use Laravel's Query Builder as data source for your dataTables. -You can look at `Yajra\DataTables\QueryDataTable` class which handles the conversion of your Query Builder into a readbale DataTable API response. +You can look at `Yajra\DataTables\QueryDataTable` class which handles the conversion of your Query Builder into a readable DataTable API response. ## Query Builder via Factory From adc481f7675d2c4d3438b7fec5c501bc18680475 Mon Sep 17 00:00:00 2001 From: 3s777 <3s777@rambler.ru> Date: Tue, 28 Apr 2020 10:35:34 +0300 Subject: [PATCH 185/264] Update relationships.md --- relationships.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/relationships.md b/relationships.md index ab91039..cccbd46 100644 --- a/relationships.md +++ b/relationships.md @@ -47,6 +47,10 @@ Looking at `{data: 'posts', name: 'posts.title'},`: - `data: posts` represents the data key (`data.posts`) that we are going to display on our table. - `name: posts.title` represents the `User` model relationship (`posts`) and the column we are going to perform our search (`title`). +It is advised that you include select('table.') on query to avoid weird issues where id from related model replaces the id of the main model. +```php +$posts = Post::with('user')->select('posts.*'); +``` ## Nested Relationships Same strategy goes for nested relationships but do **NOTE** that ordering is not yet fully tested on nested relationships. From 3b9e9f80edd65cfa24d67f3e2f6fc1dfd7eaead4 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 8 May 2020 10:41:56 +0800 Subject: [PATCH 186/264] Fix https://github.com/yajra/laravel-datatables/issues/2387. --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 5cab060..8255b13 100644 --- a/installation.md +++ b/installation.md @@ -22,7 +22,7 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ```bash -composer require yajra/laravel-datatables-oracle:^9.0 +composer require yajra/laravel-datatables-oracle:"~9.0" ``` If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. From 2a7d186e1b15acd3ae6240c533354ee8ba13ce9e Mon Sep 17 00:00:00 2001 From: Michael Newton Date: Tue, 6 Oct 2020 10:27:10 -0600 Subject: [PATCH 187/264] fix broken link in sidebar resolves yajra/laravel-datatables #2423 --- documentation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation.md b/documentation.md index cf92ae2..b577d8a 100644 --- a/documentation.md +++ b/documentation.md @@ -41,8 +41,8 @@ - [Remove Column](/docs/{{package}}/{{version}}/remove-column) - [Index Column](/docs/{{package}}/{{version}}/index-column) - [Raw Columns](/docs/{{package}}/{{version}}/raw-columns) - - [Export Columns](/docs/{{package}}/{{version}}/export-columns) - - [Print Columns](/docs/{{package}}/{{version}}/print-columns) + - [Export Columns](/docs/{{package}}/{{version}}/export-column) + - [Print Columns](/docs/{{package}}/{{version}}/print-column) - ## Row Editing - [Row Options](/docs/{{package}}/{{version}}/row-options) From 941dd740c0c1f57ff568e8ba23a0cdc02a666f96 Mon Sep 17 00:00:00 2001 From: Red Redimano Date: Wed, 7 Oct 2020 12:02:54 +0800 Subject: [PATCH 188/264] Add disable ordering sample code. --- order-column.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/order-column.md b/order-column.md index 0b78517..6413db8 100644 --- a/order-column.md +++ b/order-column.md @@ -31,4 +31,17 @@ Route::get('user-data', function () { $query->orderBy('status', $order); }); }); +``` + +Disable ordering via orderColumn. + +```php +use DataTables; + +Route::get('user-data', function () { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->orderColumn('name', false); +}); ``` \ No newline at end of file From f60a0758ace316fd62914338ecc881431ec58e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20A=C5=9Fan?= Date: Fri, 20 Nov 2020 04:35:46 +0300 Subject: [PATCH 189/264] Typo corrected --- html-builder-table.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-table.md b/html-builder-table.md index 4069f36..285a6da 100644 --- a/html-builder-table.md +++ b/html-builder-table.md @@ -21,7 +21,7 @@ Route::get('users', function(Builder $builder) { ['data' => 'name', 'footer' => 'Name'], ['data' => 'email', 'footer' => 'Email'], ['data' => 'created_at', 'footer' => 'Created At'], - ['data' => 'updated_at', 'footer' => 'Updated At'), + ['data' => 'updated_at', 'footer' => 'Updated At'], ]); return view('users.index', compact('html')); From 399916ccc9c3400fb00b238edf7e511076f427ad Mon Sep 17 00:00:00 2001 From: fransiscusrolandamalau Date: Mon, 30 Nov 2020 08:08:29 +0700 Subject: [PATCH 190/264] Typo --- html-builder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder.md b/html-builder.md index f8204f0..7faf9c1 100644 --- a/html-builder.md +++ b/html-builder.md @@ -51,7 +51,7 @@ Route::get('users', function(Builder $builder) { ['data' => 'name', 'name' => 'name', 'title' => 'Name'], ['data' => 'email', 'name' => 'email', 'title' => 'Email'], ['data' => 'created_at', 'name' => 'created_at', 'title' => 'Created At'], - ['data' => 'updated_at', 'name' => 'updated_at', 'title' => 'Updated At']), + ['data' => 'updated_at', 'name' => 'updated_at', 'title' => 'Updated At'], ]); return view('users.index', compact('html')); From 9e19825d3bb8a0263dbdbd4fef59de38519bb151 Mon Sep 17 00:00:00 2001 From: "Arjay Q. Angeles" Date: Fri, 19 Mar 2021 18:09:43 +0800 Subject: [PATCH 191/264] Add Laravel Excel and FastExcel quick integration docs. --- buttons-fast-excel.md | 58 +++++++++++++++++++++++++++++++++++++++ buttons-laravel-excel.md | 59 ++++++++++++++++++++++++++++++++++++++++ documentation.md | 2 ++ 3 files changed, 119 insertions(+) create mode 100644 buttons-fast-excel.md create mode 100644 buttons-laravel-excel.md diff --git a/buttons-fast-excel.md b/buttons-fast-excel.md new file mode 100644 index 0000000..809ba75 --- /dev/null +++ b/buttons-fast-excel.md @@ -0,0 +1,58 @@ +# Fast Excel Integration + +[Fast-Excel](https://github.com/rap2hpoutre/fast-excel) is recommended when exporting bulk records. + +## Usage + +1. Install `fast-excel` using `composer require rap2hpoutre/fast-excel`. +2. Create a dataTable class `php artisan datatables:make Users` +3. Adjust `UsersDataTable` as needed. +4. Set property `$fastExcel = true`. + +```php +class UsersDataTable extends DataTable +{ + protected $fastExcel = true; + + ... +} +``` + +5. DataTables will now export csv & excel using `fast-excel` package. + + +## Faster export by disabling the fast-excel callback + +1. Just set property `$fastExcelCallback = false`. This is enabled by default for a better formatted output of exported file. + +```php +class UsersDataTable extends DataTable +{ + protected $fastExcel = true; + protected $fastExcelCallback = false; + +``` + +2. Exported file will now be based on how your query was structured. No header formatting and all selected columns in sql will be included in the output. + +## Using custom callback + +Just override the `fastExcelCallback` method: + +```php +class UsersDataTable extends DataTable +{ + protected $fastExcel = true; + + public function fastExcelCallback() + { + return function ($row) { + return [ + 'Name' => $row['name'], + 'Email' => $row['email'], + ]; + }; + } + +... +``` \ No newline at end of file diff --git a/buttons-laravel-excel.md b/buttons-laravel-excel.md new file mode 100644 index 0000000..3756cb3 --- /dev/null +++ b/buttons-laravel-excel.md @@ -0,0 +1,59 @@ +# Laravel Excel Integration + +[Laravel Excel](https://github.com/Maatwebsite/Laravel-Excel) is the default package used when exporting DataTables to Excel and CSV. + +## Using Export Class + +1. Create an export class `php artisan make:export UsersExport` +2. Update the generated export class and extend `DataTablesCollectionExport` + +```php +namespace App\Exports; + +use Yajra\DataTables\Exports\DataTablesCollectionExport; + +class UsersExport extends DataTablesCollectionExport +{ + +} +``` + +3. Update your `UsersDataTable` class and set `protected $exportClass = UsersExport::class` + +```php +class UsersDataTable extends DataTable +{ + protected $exportClass = UsersExport::class; + +``` + +4. Update your export class as needed. See official package docs: https://docs.laravel-excel.com/3.1/exports/collection.html + +## Example Export Class + +```php +namespace App\Exports; + +use Maatwebsite\Excel\Concerns\WithMapping; +use Yajra\DataTables\Exports\DataTablesCollectionExport; + +class UsersExport extends DataTablesCollectionExport implements WithMapping +{ + public function headings(): array + { + return [ + 'Name', + 'Email', + ]; + } + + public function map($row): array + { + return [ + $row['name'], + $row['email'], + ]; + } +} +``` + diff --git a/documentation.md b/documentation.md index b577d8a..c8ca946 100644 --- a/documentation.md +++ b/documentation.md @@ -103,6 +103,8 @@ - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - [Buttons Command](/docs/{{package}}/{{version}}/buttons-console) + - [Laravel Excel Export](/docs/{{package}}/{{version}}/buttons-laravel-excel) + - [Fast Excel Export](/docs/{{package}}/{{version}}/buttons-fast-excel) - [Github](https://github.com/yajra/laravel-datatables-buttons) - ## Editor From c87047bfaebc687f7ea0ff7b371778653da9d46b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 30 Sep 2021 08:51:21 +0800 Subject: [PATCH 192/264] Add notes for the limitations. --- buttons-fast-excel.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buttons-fast-excel.md b/buttons-fast-excel.md index 809ba75..d610c4b 100644 --- a/buttons-fast-excel.md +++ b/buttons-fast-excel.md @@ -1,6 +1,10 @@ # Fast Excel Integration -[Fast-Excel](https://github.com/rap2hpoutre/fast-excel) is recommended when exporting bulk records. +[Fast-Excel](https://github.com/rap2hpoutre/fast-excel) is recommended when exporting bulk records. + +## LIMITATIONS! + +FastExcel integration uses cursor behind the scene thus eager loaded columns will not work on export. You must used join statements if you want to export related columns. Also, column value formatting like converting boolean to Yes or No should be done on SQL LEVEL. ## Usage From 2e7080f69c69b56aff0cda1059762ea5c123eb96 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 30 Sep 2021 08:57:13 +0800 Subject: [PATCH 193/264] Fix typo. --- buttons-fast-excel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-fast-excel.md b/buttons-fast-excel.md index d610c4b..fa04177 100644 --- a/buttons-fast-excel.md +++ b/buttons-fast-excel.md @@ -4,7 +4,7 @@ ## LIMITATIONS! -FastExcel integration uses cursor behind the scene thus eager loaded columns will not work on export. You must used join statements if you want to export related columns. Also, column value formatting like converting boolean to Yes or No should be done on SQL LEVEL. +FastExcel integration uses cursor behind the scene thus eager loaded columns will not work on export. You MUST use join statements if you want to export related columns. Also, column value formatting like converting boolean to Yes or No should be done on SQL LEVEL. ## Usage From 379060c29bd19f5b74022f2acd783612f922ad31 Mon Sep 17 00:00:00 2001 From: schonhoff <42345405+schonhoff@users.noreply.github.com> Date: Sat, 26 Mar 2022 23:31:45 +0100 Subject: [PATCH 194/264] Added setRowId description Added the setRowId documentation mentioned in https://github.com/yajra/laravel-datatables/issues/2661#issuecomment-883857714 --- index-column.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/index-column.md b/index-column.md index a962ef9..0afb93a 100644 --- a/index-column.md +++ b/index-column.md @@ -16,4 +16,20 @@ Route::get('user-data', function() { ``` Using `addIndexColumn` will add another column on your response with a column name that is set on [`index_column`](/docs/{{package}}/{{version}}/general-settings#index-column) configuration. -The default index column name is `DT_RowIndex` +The default index column name is `DT_RowIndex`. + +If you want to customize the index used by the `DT_RowIndex`, you can use `setRowId('COLUMN')` to change the index number. + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->setRowId('id') + ->toJson(); +}); +``` + +Be careful with this option, an index should be unique and an integer to be useful for DataTables. From cd867fbc24d7e7c8786e83b5b751f7498c9fdeee Mon Sep 17 00:00:00 2001 From: Arne Perschke Date: Thu, 7 Jul 2022 10:58:16 +0200 Subject: [PATCH 195/264] Added SearchPanes documentation --- documentation.md | 5 ++ quick-starter.md | 8 ++- search-panes-hide-columns.md | 14 +++++ search-panes-options.md | 30 ++++++++++ search-panes-starter.md | 112 +++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 search-panes-hide-columns.md create mode 100644 search-panes-options.md create mode 100644 search-panes-starter.md diff --git a/documentation.md b/documentation.md index c8ca946..9e57f17 100644 --- a/documentation.md +++ b/documentation.md @@ -65,6 +65,11 @@ - [Order Columns](/docs/{{package}}/{{version}}/order-columns) - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) +- ## SearchPanes + - [Add SearchPanes](/docs/{{package}}/{{version}}/search-panes-starter.md) + - [Hide Columns in SearchPanes](/docs/{{package}}/{{version}}/search-panes-hide-columns.md) + - [Further options](/docs/{{package}}/{{version}}/search-panes-options.md) + - ## Utilities - [XSS filtering](/docs/{{package}}/{{version}}/xss) - [Blacklist Columns](/docs/{{package}}/{{version}}/blacklist) diff --git a/quick-starter.md b/quick-starter.md index 6d152b0..57c976b 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -31,9 +31,11 @@ php artisan ui bootstrap --auth ## Install Datatables.net assets ``` -yarn add datatables.net-bs4 datatables.net-buttons-bs4 +yarn add datatables.net-bs4 datatables.net-buttons-bs4 datatables.net-select-bs4 datatables.net-searchpanes-bs4 ``` +> {tip} datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are only required if you want to use SearchPanes + ## Register datatables.net assets in bootstrap.js and app.scss Edit `resources/js/bootstrap.js` and add the following: @@ -41,12 +43,16 @@ Edit `resources/js/bootstrap.js` and add the following: require('bootstrap'); require('datatables.net-bs4'); require('datatables.net-buttons-bs4'); + require('datatables.net-select-bs4'); + require('datatables.net-searchpanes-bs4'); Edit `resources/scss/app.scss` and add the following: // DataTables @import "~datatables.net-bs4/css/dataTables.bootstrap4.css"; @import "~datatables.net-buttons-bs4/css/buttons.bootstrap4.css"; + @import '~datatables.net-select-bs4/css/select.dataTables.css'; + @import '~datatables.net-searchpanes-dt/css/searchPanes.dataTables.css'; ## Compile assets diff --git a/search-panes-hide-columns.md b/search-panes-hide-columns.md new file mode 100644 index 0000000..3064861 --- /dev/null +++ b/search-panes-hide-columns.md @@ -0,0 +1,14 @@ +# Hide Columns in SearchPanes + +Some columns you might not want in your SearchPanes, to hide them you can add `->searchPanes(false)` in your column +definition: + +```php +protected function getColumns() : array +{ + return [ + Column::make('id') + ->searchPanes(false); + ] +} +``` \ No newline at end of file diff --git a/search-panes-options.md b/search-panes-options.md new file mode 100644 index 0000000..4026db4 --- /dev/null +++ b/search-panes-options.md @@ -0,0 +1,30 @@ +# Further SearchPanes options + +```php +public function html() : \Yajra\DataTables\Html\Builder +{ + return $this->builder() + ->searchPanes( + SearchPane::make() + ->hideCount() // Hides the count next to the options, the amount of records with the filters + ->hideTotal() // Hides the total how many are available without the filters + ->clear(false) // Hides the clear button, used to clear the user selection + ->controls(false) // disable controls (search for filters) + ->layout('columns-2') // can be used to set the layout (amount of search panes in one row) + ->order(['user_id', 'age']) // Sets the order of the search panes, uses the name of the search pane + ->orderable(false) // If the order icons should be displayed in the interface + ->panes( // Can be used to add additional search panes which do not belong to any existing column + [ + // SearchPane::make()... + ] + ) + ->dtOpts( // Sets the options for the datatables inside the searchpanes + [ + 'paging' => true, + 'pagingType' => 'numbers' + ] + ) + + ); +} +``` diff --git a/search-panes-starter.md b/search-panes-starter.md new file mode 100644 index 0000000..a9c96e9 --- /dev/null +++ b/search-panes-starter.md @@ -0,0 +1,112 @@ +# Add SearchPane + +[SearchPanes](https://datatables.net/extensions/searchpanes/) ([example](https://datatables.net/extensions/searchpanes/examples/initialisation/simple.html)) +allow the user to quickly filter the datatable after predefined filters. + +> {note} To use datatables you need to make sure that the npm packages `datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are installed and added to your `app.js`/`app.css` files. + +## Adding SearchPanes to the frontend + +To be able to see SearchPanes you need to either add them fixed in the dom (displayed at all time) or add a button which +opens them as popup. + +### Adding SearchPanes fixed in the dom + +SearchPanes can be added to a table via the dom string, in it, they are marked with a `P` if you for example +are using `Bfrtip` as dom you can use `PBfrtip` to display the SearchPanes at the top of the datatable, or `BfrtipP` +to display them at the very bottom. + +Setting the dom String with the `\Yajra\DataTables\Html\Builder`: +```php +public function html() : \Yajra\DataTables\Html\Builder +{ + // Setting the dom string directly + return $this->builder() + ->searchPanes(SearchPane::make()) + ->dom('PBfrtip'); + + // Alternatively set the dom with parameters + return $this->builder() + ->searchPanes(SearchPane::make()) + ->parameters([ + 'dom' => 'PBfrtip' + ]); +} +``` + +### Adding SearchPanes with a button + +To add a button which opens the SearchPanes you need to make one extending `searchPanes`: + +```php +public function html() : \Yajra\DataTables\Html\Builder +{ + // Adding via class + return $this->builder() + ->searchPanes(SearchPane::make()) + ->buttons([ + \Yajra\DataTables\Html\Button::make('searchPanes') + // other buttons... + ]); + + // Alternatively set the buttons with options + return $this->builder() + ->searchPanes(SearchPane::make()) + ->parameters([ + 'buttons' => ['searchPanes', /*other buttons...*/] + ]); +} +``` + +## Adding SearchPanes to the backend + +The SearchPanes can be filled in the datatables declaration via the `searchPane()` method. The method takes the column +for which the SearchPane is, as well as the options of the SearchPane. It also allows you to set custom processing for +the options. + + +```php +public function dataTable($query) : Yajra\DataTables\DataTableAbstract +{ + return datatables() + ->eloquent($query) + // Adding the SearchPane + ->searchPane( + /* + * This is the column for which this SearchPane definition is for + */ + 'user_id', + + /* + * Here we define the options for our SearchPane. This should be either a collection or an array with the + * form: + * [ + * [ + * 'value' => 1, + * 'label' => 'display value', + * 'total' => 5, // optional + * 'count' => 3 // optional + * ], + * [ + * 'value' => 2, + * 'label' => 'display value 2', + * 'total' => 6, // optional + * 'count' => 5 // optional + * ], + * ] + */ + fn() => User::query()->select('id as value', 'name as label')->get(), + + /* + * This is the filter that gets executed when the user selects one or more values on the SearchPane. The + * values are always given in an array even if just one is selected + */ + function (\Illuminate\Database\Eloquent\Builder $query, array $values) { + return $query + ->whereIn( + 'id', + $values); + } + ); +} +``` From 13c637127c8ca6800dadf1ba02dd3e8a9b5367d4 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 13:46:35 +0800 Subject: [PATCH 196/264] Fix link --- documentation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation.md b/documentation.md index 9e57f17..be4d6d7 100644 --- a/documentation.md +++ b/documentation.md @@ -66,9 +66,9 @@ - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) - ## SearchPanes - - [Add SearchPanes](/docs/{{package}}/{{version}}/search-panes-starter.md) - - [Hide Columns in SearchPanes](/docs/{{package}}/{{version}}/search-panes-hide-columns.md) - - [Further options](/docs/{{package}}/{{version}}/search-panes-options.md) + - [Add SearchPanes](/docs/{{package}}/{{version}}/search-panes-starter) + - [Hide Columns in SearchPanes](/docs/{{package}}/{{version}}/search-panes-hide-columns) + - [Further options](/docs/{{package}}/{{version}}/search-panes-options) - ## Utilities - [XSS filtering](/docs/{{package}}/{{version}}/xss) From 7e7a09c16e93712ab4ccb37148561aba581920ba Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:14:02 +0800 Subject: [PATCH 197/264] Bump version to L9 --- installation.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/installation.md b/installation.md index 8255b13..2db07f1 100644 --- a/installation.md +++ b/installation.md @@ -11,7 +11,7 @@ ### Requirements -- [Laravel 5.5+](https://github.com/laravel/framework) +- [Laravel 9+](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) @@ -22,13 +22,13 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ```bash -composer require yajra/laravel-datatables-oracle:"~9.0" +composer require yajra/laravel-datatables-oracle:"^10.0" ``` If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. ```bash -composer require yajra/laravel-datatables:^1.5 +composer require yajra/laravel-datatables:^9.0 ``` From 195e19a71da2b50914304f279759a8769f9deab3 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:21:48 +0800 Subject: [PATCH 198/264] Add deprecation notes --- skip-total-records.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skip-total-records.md b/skip-total-records.md index aa00a6b..0400387 100644 --- a/skip-total-records.md +++ b/skip-total-records.md @@ -1,5 +1,7 @@ # Skip Total Records +> Note: This is deprecated on v10. Just use setTotalRecords instead. + Skip total records aims to improve dataTables response time by skipping the total records count query and settings its value equals to the filtered total records. From c47b26387b985c276045497181b741df269bf894 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:25:22 +0800 Subject: [PATCH 199/264] Bump to v9 --- buttons-installation.md | 2 +- html-installation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buttons-installation.md b/buttons-installation.md index 27ef960..9deaf74 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -2,7 +2,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^4.0` +`composer require yajra/laravel-datatables-buttons:^9.0` ## Configuration > This step is optional if you are using Laravel 5.5 diff --git a/html-installation.md b/html-installation.md index a1e08f6..a4f7a1d 100644 --- a/html-installation.md +++ b/html-installation.md @@ -4,7 +4,7 @@ Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^4.0` +`composer require yajra/laravel-datatables-html:^9.0` ## Configuration > This step is optional if you are using Laravel 5.5 From a41c7ba7313a518641083dae8fef6b69945cd28a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:28:06 +0800 Subject: [PATCH 200/264] Add fractal plugin section --- documentation.md | 77 +++++++++++++++++++++-------------------- fractal-installation.md | 24 +++++++++++++ 2 files changed, 64 insertions(+), 37 deletions(-) create mode 100644 fractal-installation.md diff --git a/documentation.md b/documentation.md index be4d6d7..74bce65 100644 --- a/documentation.md +++ b/documentation.md @@ -28,8 +28,6 @@ - ## Response - [Array Response](/docs/{{package}}/{{version}}/response-array) - [Object Response](/docs/{{package}}/{{version}}/response-object) - - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - [Additional Data Response](/docs/{{package}}/{{version}}/response-with) - [Only Columns](/docs/{{package}}/{{version}}/response-only) - [Response Resource](/docs/{{package}}/{{version}}/response-resource) @@ -82,42 +80,47 @@ ### PLUGINS - ## HTML Builder - - [Installation](/docs/{{package}}/{{version}}/html-installation) - - [Builder](/docs/{{package}}/{{version}}/html-builder) - - [Table](/docs/{{package}}/{{version}}/html-builder-table) - - [Config](/docs/{{package}}/{{version}}/html-builder-config) - - [Columns](/docs/{{package}}/{{version}}/html-builder-column) - - [Column Builder](/docs/{{package}}/{{version}}/html-builder-column-builder) - - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) - - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) - - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) - - [Post Ajax](/docs/{{package}}/{{version}}/html-builder-post-ajax) - - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) - - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) - - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) - - [Github](https://github.com/yajra/laravel-datatables-html) + - [Installation](/docs/{{package}}/{{version}}/html-installation) + - [Builder](/docs/{{package}}/{{version}}/html-builder) + - [Table](/docs/{{package}}/{{version}}/html-builder-table) + - [Config](/docs/{{package}}/{{version}}/html-builder-config) + - [Columns](/docs/{{package}}/{{version}}/html-builder-column) + - [Column Builder](/docs/{{package}}/{{version}}/html-builder-column-builder) + - [Macro](/docs/{{package}}/{{version}}/html-builder-macro) + - [Ajax](/docs/{{package}}/{{version}}/html-builder-ajax) + - [Minified Ajax](/docs/{{package}}/{{version}}/html-builder-minified-ajax) + - [Post Ajax](/docs/{{package}}/{{version}}/html-builder-post-ajax) + - [Parameters](/docs/{{package}}/{{version}}/html-builder-parameters) + - [Events/Callbacks](/docs/{{package}}/{{version}}/html-builder-callbacks) + - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) + - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) + - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) + - [Github](https://github.com/yajra/laravel-datatables-html) - ## Buttons - - [Installation](/docs/{{package}}/{{version}}/buttons-installation) - - [Configuration](/docs/{{package}}/{{version}}/buttons-config) - - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) - - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) - - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) - - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) - - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) - - [Buttons Command](/docs/{{package}}/{{version}}/buttons-console) - - [Laravel Excel Export](/docs/{{package}}/{{version}}/buttons-laravel-excel) - - [Fast Excel Export](/docs/{{package}}/{{version}}/buttons-fast-excel) - - [Github](https://github.com/yajra/laravel-datatables-buttons) + - [Installation](/docs/{{package}}/{{version}}/buttons-installation) + - [Configuration](/docs/{{package}}/{{version}}/buttons-config) + - [Quick Starter](/docs/{{package}}/{{version}}/buttons-starter) + - [DataTable Buttons](/docs/{{package}}/{{version}}/buttons-export) + - [Custom Actions](/docs/{{package}}/{{version}}/buttons-custom) + - [Sending Parameters](/docs/{{package}}/{{version}}/buttons-with) + - [Extended DataTable](/docs/{{package}}/{{version}}/buttons-extended) + - [Buttons Command](/docs/{{package}}/{{version}}/buttons-console) + - [Laravel Excel Export](/docs/{{package}}/{{version}}/buttons-laravel-excel) + - [Fast Excel Export](/docs/{{package}}/{{version}}/buttons-fast-excel) + - [Github](https://github.com/yajra/laravel-datatables-buttons) + +- ## Fractal + - [Installation](/docs/{{package}}/{{version}}/fractal-installation) + - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) + - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) - ## Editor - - [Installation](/docs/{{package}}/{{version}}/editor-installation) - - [Editor Command](/docs/{{package}}/{{version}}/editor-command) - - [Editor Model](/docs/{{package}}/{{version}}/editor-model) - - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) - - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) - - [Usage](/docs/{{package}}/{{version}}/editor-usage) - - [Tutorial](/docs/{{package}}/{{version}}/editor-tutorial) - - [Github](https://github.com/yajra/laravel-datatables-editor) + - [Installation](/docs/{{package}}/{{version}}/editor-installation) + - [Editor Command](/docs/{{package}}/{{version}}/editor-command) + - [Editor Model](/docs/{{package}}/{{version}}/editor-model) + - [Editor Rules](/docs/{{package}}/{{version}}/editor-rules) + - [Event Hooks](/docs/{{package}}/{{version}}/editor-events) + - [Usage](/docs/{{package}}/{{version}}/editor-usage) + - [Tutorial](/docs/{{package}}/{{version}}/editor-tutorial) + - [Github](https://github.com/yajra/laravel-datatables-editor) diff --git a/fractal-installation.md b/fractal-installation.md new file mode 100644 index 0000000..c61a3e2 --- /dev/null +++ b/fractal-installation.md @@ -0,0 +1,24 @@ +# Fractal Plugin Installation + +Run the following command in your project to get the latest version of the plugin: + +`composer require yajra/laravel-datatables-fractal:^9.0` + +## Configuration +> This step is optional if you are using Laravel 5.5 + +Open the file ```config/app.php``` and then add following service provider. + +```php +'providers' => [ + // ... + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\FractalServiceProvider::class, +], +``` + +After completing the step above, use the following command to publish configuration & assets: + +``` +php artisan vendor:publish --tag=datatables-buttons +``` From 7dd6959a78152cfd1117cb53983755ee45406a3a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:29:53 +0800 Subject: [PATCH 201/264] Fix publish cmd --- fractal-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fractal-installation.md b/fractal-installation.md index c61a3e2..16bfdb4 100644 --- a/fractal-installation.md +++ b/fractal-installation.md @@ -20,5 +20,5 @@ Open the file ```config/app.php``` and then add following service provider. After completing the step above, use the following command to publish configuration & assets: ``` -php artisan vendor:publish --tag=datatables-buttons +php artisan vendor:publish --tag=datatables-fractal --force ``` From 5f3347e3da9eca2a58eb1544ccdf9f41d9d5a473 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:40:05 +0800 Subject: [PATCH 202/264] Add section for export plugin --- documentation.md | 3 +++ exports-installation.md | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 exports-installation.md diff --git a/documentation.md b/documentation.md index 74bce65..d284b48 100644 --- a/documentation.md +++ b/documentation.md @@ -115,6 +115,9 @@ - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) +- ## Livewire + Batch Job Exports + - [Installation](/docs/{{package}}/{{version}}/exports-installation) + - ## Editor - [Installation](/docs/{{package}}/{{version}}/editor-installation) - [Editor Command](/docs/{{package}}/{{version}}/editor-command) diff --git a/exports-installation.md b/exports-installation.md new file mode 100644 index 0000000..3788d3a --- /dev/null +++ b/exports-installation.md @@ -0,0 +1,27 @@ +# Export Plugin Installation + +Github: https://github.com/yajra/laravel-datatables-export + +Run the following command in your project to get the latest version of the plugin: + +`composer require yajra/laravel-datatables-export:^0.12` + +## Configuration + +> This step is optional if you are using Laravel 5.5 + +Open the file ```config/app.php``` and then add following service provider. + +```php +'providers' => [ + // ... + Yajra\DataTables\DataTablesServiceProvider::class, + Yajra\DataTables\ExportServiceProvider::class, +], +``` + +After completing the step above, use the following command to publish configuration & assets: + +``` +php artisan vendor:publish --tag=datatables-export --force +``` From eed782b0d2b98fa71ce526ddbc5585c035090668 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:40:05 +0800 Subject: [PATCH 203/264] Add section for export plugin --- buttons-installation.md | 2 ++ fractal-installation.md | 2 ++ html-installation.md | 3 +++ 3 files changed, 7 insertions(+) diff --git a/buttons-installation.md b/buttons-installation.md index 9deaf74..424966c 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -1,5 +1,7 @@ # Buttons Plugin Installation +Github: https://github.com/yajra/laravel-datatables-buttons + Run the following command in your project to get the latest version of the plugin: `composer require yajra/laravel-datatables-buttons:^9.0` diff --git a/fractal-installation.md b/fractal-installation.md index 16bfdb4..e210f6b 100644 --- a/fractal-installation.md +++ b/fractal-installation.md @@ -1,5 +1,7 @@ # Fractal Plugin Installation +Github: https://github.com/yajra/laravel-datatables-fractal + Run the following command in your project to get the latest version of the plugin: `composer require yajra/laravel-datatables-fractal:^9.0` diff --git a/html-installation.md b/html-installation.md index a4f7a1d..507ce61 100644 --- a/html-installation.md +++ b/html-installation.md @@ -2,11 +2,14 @@ ## Installation +Github: https://github.com/yajra/laravel-datatables-html + Run the following command in your project to get the latest version of the plugin: `composer require yajra/laravel-datatables-html:^9.0` ## Configuration + > This step is optional if you are using Laravel 5.5 Open the file ```config/app.php``` and then add following service provider. From 83f08d688e6006c077cf23d416586d8a08caee11 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:43:39 +0800 Subject: [PATCH 204/264] Use docs from repo --- documentation.md | 2 +- exports-installation.md | 31 +++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/documentation.md b/documentation.md index d284b48..4d760f9 100644 --- a/documentation.md +++ b/documentation.md @@ -115,7 +115,7 @@ - [Fractal Transformer](/docs/{{package}}/{{version}}/response-fractal) - [Fractal Serializer](/docs/{{package}}/{{version}}/response-fractal-serializer) -- ## Livewire + Batch Job Exports +- ## Export - [Installation](/docs/{{package}}/{{version}}/exports-installation) - ## Editor diff --git a/exports-installation.md b/exports-installation.md index 3788d3a..79dd9fa 100644 --- a/exports-installation.md +++ b/exports-installation.md @@ -2,26 +2,29 @@ Github: https://github.com/yajra/laravel-datatables-export -Run the following command in your project to get the latest version of the plugin: +This package is a plugin of Laravel DataTables for handling server-side exporting using Queue, OpenSpout and Livewire. -`composer require yajra/laravel-datatables-export:^0.12` +## Quick Installation -## Configuration - -> This step is optional if you are using Laravel 5.5 +``` +composer require yajra/laravel-datatables-export -W +``` -Open the file ```config/app.php``` and then add following service provider. +The package also requires batch job: -```php -'providers' => [ - // ... - Yajra\DataTables\DataTablesServiceProvider::class, - Yajra\DataTables\ExportServiceProvider::class, -], +``` +php artisan queue:batches-table +php artisan migrate ``` -After completing the step above, use the following command to publish configuration & assets: +## Service Provider (Optional since Laravel 5.5+) ``` -php artisan vendor:publish --tag=datatables-export --force +Yajra\DataTables\ExportServiceProvider::class +``` + +## Configuration and Assets (Optional) + ``` +$ php artisan vendor:publish --tag=datatables-export --force +``` \ No newline at end of file From e80661f9c755944c5374fcb0621f18d96403165d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:47:28 +0800 Subject: [PATCH 205/264] Add more export docs --- exports-usage.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 exports-usage.md diff --git a/exports-usage.md b/exports-usage.md new file mode 100644 index 0000000..f5d6a29 --- /dev/null +++ b/exports-usage.md @@ -0,0 +1,24 @@ +# Export Usage + +## Usage + +1. Add the export-button livewire component on your view file that uses dataTable class. + +```php + +``` + +2. On your `DataTable` class, use `WithExportQueue` + +```php +use Yajra\DataTables\WithExportQueue; + +class PermissionsDataTable extends DataTable +{ + use WithExportQueue; + + ... +} +``` + +3. Run your queue worker. Ex: `php artisan queue:work` From e65838bb600fa1493e44920aa632880965942bc7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:47:28 +0800 Subject: [PATCH 206/264] Add more export docs --- documentation.md | 3 ++ exports-options.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++ exports-purge.md | 20 ++++++++++ 3 files changed, 121 insertions(+) create mode 100644 exports-options.md create mode 100644 exports-purge.md diff --git a/documentation.md b/documentation.md index 4d760f9..9a7b5e9 100644 --- a/documentation.md +++ b/documentation.md @@ -117,6 +117,9 @@ - ## Export - [Installation](/docs/{{package}}/{{version}}/exports-installation) + - [Usage](/docs/{{package}}/{{version}}/exports-usage) + - [Purge](/docs/{{package}}/{{version}}/exports-purge) + - [Options](/docs/{{package}}/{{version}}/exports-options) - ## Editor - [Installation](/docs/{{package}}/{{version}}/editor-installation) diff --git a/exports-options.md b/exports-options.md new file mode 100644 index 0000000..895d397 --- /dev/null +++ b/exports-options.md @@ -0,0 +1,98 @@ +# Export Options + +## Export Type + +You can set the export type by setting the property to `csv` or `xlsx`. Default value is `xlsx`. + +```php + + +``` + +## Set Excel Sheet Name + +Option 1: You can set the Excel sheet name by setting the property. + +```php + +``` + +Option 2: You can also set the Excel sheet name by overwriting the method. + +```php +protected function sheetName() : string +{ + return "Yearly Report"; +} +``` + +## Formatting Columns + +You can format the column by setting it via Column definition on you DataTable service class. + +```php +Column::make('mobile')->exportFormat('00000000000'), +``` + +The format above will treat mobile numbers as text with leading zeroes. + +## Numeric Fields Formatting + +The package will auto-detect numeric fields and can be used with custom formats. + +```php +Column::make('total')->exportFormat('0.00'), +Column::make('count')->exportFormat('#,##0'), +Column::make('average')->exportFormat('#,##0.00'), +``` + +## Date Fields Formatting + +The package will auto-detect date fields when used with a valid format or is a DateTime instance. + +```php +Column::make('report_date')->exportFormat('mm/dd/yyyy'), +Column::make('created_at'), +Column::make('updated_at')->exportFormat(NumberFormat::FORMAT_DATE_DATETIME), +``` + +## Valid Date Formats + +Valid date formats can be adjusted on `datatables-export.php` config file. + +```php + 'date_formats' => [ + 'mm/dd/yyyy', + NumberFormat::FORMAT_DATE_DATETIME, + NumberFormat::FORMAT_DATE_YYYYMMDD, + NumberFormat::FORMAT_DATE_XLSX22, + NumberFormat::FORMAT_DATE_DDMMYYYY, + NumberFormat::FORMAT_DATE_DMMINUS, + NumberFormat::FORMAT_DATE_DMYMINUS, + NumberFormat::FORMAT_DATE_DMYSLASH, + NumberFormat::FORMAT_DATE_MYMINUS, + NumberFormat::FORMAT_DATE_TIME1, + NumberFormat::FORMAT_DATE_TIME2, + NumberFormat::FORMAT_DATE_TIME3, + NumberFormat::FORMAT_DATE_TIME4, + NumberFormat::FORMAT_DATE_TIME5, + NumberFormat::FORMAT_DATE_TIME6, + NumberFormat::FORMAT_DATE_TIME7, + NumberFormat::FORMAT_DATE_XLSX14, + NumberFormat::FORMAT_DATE_XLSX15, + NumberFormat::FORMAT_DATE_XLSX16, + NumberFormat::FORMAT_DATE_XLSX17, + NumberFormat::FORMAT_DATE_YYYYMMDD2, + NumberFormat::FORMAT_DATE_YYYYMMDDSLASH, + ] +``` + +## Force Numeric Field As Text Format + +Option to force auto-detected numeric value as text format. + +```php +Column::make('id')->exportFormat('@'), +Column::make('id')->exportFormat(NumberFormat::FORMAT_GENERAL), +Column::make('id')->exportFormat(NumberFormat::FORMAT_TEXT), +``` diff --git a/exports-purge.md b/exports-purge.md new file mode 100644 index 0000000..241af22 --- /dev/null +++ b/exports-purge.md @@ -0,0 +1,20 @@ +# Export Usage + +## Purging exported files + +On `app\Console\Kernel.php`, register the purge command + +```php +$schedule->command('datatables:purge-export')->weekly(); +``` + +## Export Filename + +You can set the export filename by setting the property. + +```php + + + + +``` From 6eade255b62b495ee637de274e3a30fc4af39880 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 14 Jul 2022 14:49:21 +0800 Subject: [PATCH 207/264] Remove file --- exports-purge.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/exports-purge.md b/exports-purge.md index 241af22..ee246f1 100644 --- a/exports-purge.md +++ b/exports-purge.md @@ -7,14 +7,3 @@ On `app\Console\Kernel.php`, register the purge command ```php $schedule->command('datatables:purge-export')->weekly(); ``` - -## Export Filename - -You can set the export filename by setting the property. - -```php - - - - -``` From dada81b0ab110757fcc938bcee7859c91aba3f07 Mon Sep 17 00:00:00 2001 From: Hamees Ahmed Khan <32523517+hameesakhan@users.noreply.github.com> Date: Tue, 19 Jul 2022 20:38:59 +0500 Subject: [PATCH 208/264] Added missing quote to highlight library names --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 57c976b..152b3a6 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -34,7 +34,7 @@ php artisan ui bootstrap --auth yarn add datatables.net-bs4 datatables.net-buttons-bs4 datatables.net-select-bs4 datatables.net-searchpanes-bs4 ``` -> {tip} datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are only required if you want to use SearchPanes +> {tip} `datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are only required if you want to use SearchPanes ## Register datatables.net assets in bootstrap.js and app.scss From 94275f29f04631f93d2a1f6a48d188a2e3680ae9 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 13 Oct 2022 17:42:29 +0800 Subject: [PATCH 209/264] remove api --- documentation.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/documentation.md b/documentation.md index 9a7b5e9..226ef6a 100644 --- a/documentation.md +++ b/documentation.md @@ -2,11 +2,10 @@ - [Release Notes](/docs/{{package}}/{{version}}/releases) - [Upgrade Guide](/docs/{{package}}/{{version}}/upgrade) - [Contribution Guide](/docs/{{package}}/{{version}}/contributing) - - [Security Issues](/docs/{{package}}/{{version}}/security) - - [API Documentation](http://yajra.github.io/{{package}}/api/{{version}}) + - [Security Issues](/docs/{{package}}/{{version}}/security) - ## Getting Started - - [Introduction](/docs/{{package}}/{{version}}/introduction) + - [Introduction](/docs/{{package}}/{{version}}/introduction) - [Installation](/docs/{{package}}/{{version}}/installation) - [Demo Application](https://datatables.yajrabox.com/) - [Community Links](/docs/{{package}}/{{version}}/community-links) From b0999aab39084bb755a78535c89aa43c8785e514 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 19 Oct 2022 10:28:19 +0800 Subject: [PATCH 210/264] docs: update quick starter to work with vitejs --- quick-starter.md | 225 +++++++++++++++++++++++++---------------------- 1 file changed, 119 insertions(+), 106 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 152b3a6..85f03e7 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,161 +1,143 @@ # DataTables Quick Starter -## Create new project +## Create a new Laravel project ``` laravel new datatables cd datatables -cp .env.example .env -php artisan key:generate ``` -## Setup database and ENV configuration +## Setup Laravel UI -Create a new database and update `.env` file and set the datbase credentials. +```shell +composer require laravel/ui --dev +php artisan ui bootstrap --auth +``` -## Install package and publish assets +## Install Laravel DataTables +```shell +composer require yajra/laravel-datatables:^9.0 ``` -composer require yajra/laravel-datatables -php artisan vendor:publish --tag=datatables-buttons -``` +## Setup database and ENV configuration -## Setup Laravel UI +Create a new database and update `.env` file and set the database credentials. -``` -composer require laravel/ui --dev -php artisan ui bootstrap --auth +```shell +touch database/database.sqlite ``` -## Install Datatables.net assets +```dotenv +DB_CONNECTION=sqlite +DB_DATABASE=/absolute/path/to/database/database.sqlite +``` +```shell +php artisan migrate ``` -yarn add datatables.net-bs4 datatables.net-buttons-bs4 datatables.net-select-bs4 datatables.net-searchpanes-bs4 + +## Install Laravel DataTables Vite Assets + +```shell +npm i laravel-datatables-vite --save-dev ``` -> {tip} `datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are only required if you want to use SearchPanes +This will install the following packages: + +1. Bootstrap Icons +2. DataTables with Buttons and Select plugins for Bootstrap 5 +3. Laravel DataTables custom scripts -## Register datatables.net assets in bootstrap.js and app.scss +## Register the package js and css -Edit `resources/js/bootstrap.js` and add the following: +Edit `resources/js/app.js` and add the following: - require('bootstrap'); - require('datatables.net-bs4'); - require('datatables.net-buttons-bs4'); - require('datatables.net-select-bs4'); - require('datatables.net-searchpanes-bs4'); +```js +import './bootstrap'; +import 'laravel-datatables-vite'; +``` -Edit `resources/scss/app.scss` and add the following: +Edit `resources/sass/app.scss` and add the following: - // DataTables - @import "~datatables.net-bs4/css/dataTables.bootstrap4.css"; - @import "~datatables.net-buttons-bs4/css/buttons.bootstrap4.css"; - @import '~datatables.net-select-bs4/css/select.dataTables.css'; - @import '~datatables.net-searchpanes-dt/css/searchPanes.dataTables.css'; +```postcss +// Fonts +@import url('https://fonts.bunny.net/css?family=Nunito'); -## Compile assets +// Variables +@import 'variables'; -``` -yarn dev / watch / prod +// Bootstrap +@import 'bootstrap/scss/bootstrap'; + +// DataTables +@import 'bootstrap-icons/font/bootstrap-icons.css'; +@import "datatables.net-bs5/css/dataTables.bootstrap5.min.css"; +@import "datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css"; +@import 'datatables.net-select-bs5/css/select.bootstrap5.css'; ``` -## Create controller and DataTable class +## Compile the assets ``` -php artisan make:controller UsersController -php artisan datatables:make Users +npm run dev ``` -### UsersController +## Create and update UsersDataTable -```php -namespace App\Http\Controllers; - -use App\DataTables\UsersDataTable; +Create a new DataTable class: -class UsersController extends Controller -{ - public function index(UsersDataTable $dataTable) - { - return $dataTable->render('users.index'); - } -} +```shell +php artisan datatables:make Users ``` -### UsersDataTable +Then, update the `getColumns()` with the users fields: ```php namespace App\DataTables; -use App\User; +use App\Models\User; +use Illuminate\Database\Eloquent\Builder as QueryBuilder; +use Yajra\DataTables\EloquentDataTable; +use Yajra\DataTables\Html\Builder as HtmlBuilder; use Yajra\DataTables\Html\Button; use Yajra\DataTables\Html\Column; -use Yajra\DataTables\Html\Editor\Editor; -use Yajra\DataTables\Html\Editor\Fields; use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { - /** - * Build DataTable class. - * - * @param mixed $query Results from query() method. - * @return \Yajra\DataTables\DataTableAbstract - */ - public function dataTable($query) + public function dataTable(QueryBuilder $query): EloquentDataTable { - return datatables() - ->eloquent($query) - ->addColumn('action', 'users.action'); + return (new EloquentDataTable($query))->setRowId('id'); } - /** - * Get query source of dataTable. - * - * @param \App\User $model - * @return \Illuminate\Database\Eloquent\Builder - */ - public function query(User $model) + public function query(User $model): QueryBuilder { return $model->newQuery(); } - /** - * Optional method if you want to use html builder. - * - * @return \Yajra\DataTables\Html\Builder - */ - public function html() + public function html(): HtmlBuilder { return $this->builder() ->setTableId('users-table') ->columns($this->getColumns()) ->minifiedAjax() - ->dom('Bfrtip') ->orderBy(1) - ->buttons( - Button::make('create'), - Button::make('export'), + ->selectStyleSingle() + ->buttons([ + Button::make('add'), + Button::make('excel'), + Button::make('csv'), + Button::make('pdf'), Button::make('print'), Button::make('reset'), - Button::make('reload') - ); + Button::make('reload'), + ]); } - /** - * Get columns. - * - * @return array - */ - protected function getColumns() + protected function getColumns(): array { return [ - Column::computed('action') - ->exportable(false) - ->printable(false) - ->width(60) - ->addClass('text-center'), Column::make('id'), Column::make('name'), Column::make('email'), @@ -164,26 +146,48 @@ class UsersDataTable extends DataTable ]; } - /** - * Get filename for export. - * - * @return string - */ - protected function filename() + protected function filename(): string + { + return 'Users_'.date('YmdHis'); + } +} +``` + +## Create and update the users controller + +Create a new controller and add the following: + +```shell +php artisan make:controller UsersController +``` + +```php +namespace App\Http\Controllers; + +use App\DataTables\UsersDataTable; + +class UsersController extends Controller +{ + public function index(UsersDataTable $dataTable) { - return 'Users_' . date('YmdHis'); + return $dataTable->render('users.index'); } } ``` -## Update app layout +## Update the default app layout -Add scripts before the body end tag of `resources/views/layouts/app.blade.php` +Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app.blade.php` ``` - - +.... +
+ @yield('content') +
+ @stack('scripts') + + ``` ## Create users index file @@ -194,11 +198,18 @@ Create new file: `resources/views/users/index.blade.php`. @extends('layouts.app') @section('content') - {{$dataTable->table()}} +
+
+
Manage Users
+
+ {{ $dataTable->table() }} +
+
+
@endsection @push('scripts') - {{$dataTable->scripts()}} + {{ $dataTable->scripts(attributes: ['type' => 'module']) }} @endpush ``` @@ -207,7 +218,9 @@ Create new file: `resources/views/users/index.blade.php`. Update `routes/web.php`. ```php -Route::get('/users', 'UsersController@index')->name('users.index'); +use App\Http\Controllers\UsersController; + +Route::get('/users', [UsersController::class, 'index'])->name('users.index'); ``` ## Create dummy data using tinker @@ -216,7 +229,7 @@ Route::get('/users', 'UsersController@index')->name('users.index'); php artisan tinker Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman ->>> factory('App\User', 100)->create() +>>> User::factory(100)->create() ``` ## Access Users DataTables From 163a1b533c29d895196e7c3b8e4491f3dab2e7bb Mon Sep 17 00:00:00 2001 From: mark-git07 Date: Sun, 23 Oct 2022 18:51:03 +0800 Subject: [PATCH 211/264] initial revisions for a few document files v10.0 --- add-column.md | 4 ++-- buttons-config.md | 10 +++++----- buttons-console.md | 12 ++++++------ buttons-custom.md | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/add-column.md b/add-column.md index 92e82c0..d5b984c 100644 --- a/add-column.md +++ b/add-column.md @@ -1,8 +1,8 @@ # Add Column -You can add a custom column on your response by using `addColumn` api. +You can add a custom column to your response by using the `addColumn` api. -> {note} added columns are assumed to be computed columns and not part of the database. Thus, search/sort will be disabled on those columns. If you need them, use the `editColumn` api instead. +> {note} added columns are assumed to be computed columns and not part of the database. Thus, search/sort will be disabled for those columns. If you need them, use the `editColumn` api instead. ## Add Column with Blade Syntax diff --git a/buttons-config.md b/buttons-config.md index 5b4260d..817b62e 100644 --- a/buttons-config.md +++ b/buttons-config.md @@ -12,8 +12,8 @@ Namespace configuration is used by the datatables command generator. ``` ### 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. +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``` @@ -24,8 +24,8 @@ This directory is appended on default Laravel namespace. **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. +This is the base namespace/directory where your models are located. +This directory is appended to the default Laravel namespace. **Usage:** ```php artisan datatables:make Post --model``` **Output:** ```App\DataTables\PostDataTable``` **With Model:** ```App\Post`` @@ -33,7 +33,7 @@ This directory is appended on default Laravel namespace. ## PDF Generator -Set the PDF generator to be used when converting your dataTable to pdf. +Set the PDF generator to be used when converting your dataTable to PDF. Available generators are: `excel`, `snappy` diff --git a/buttons-console.md b/buttons-console.md index 7e88422..0efc0fc 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -18,7 +18,7 @@ In this example, we will create a DataTable service class. php artisan datatables:make Posts ``` -This will create an `PostsDataTable` class on `app\DataTables` directory. +This will create a `PostsDataTable` class in the `app\DataTables` directory. ```php namespace App\DataTables; @@ -101,7 +101,7 @@ In this example, we will pass a `--model` option to set the model to be used by php artisan datatables:make Posts --model ``` -This will generate a `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. +This will generate an `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. The exported filename will also be set to `posts_(timestamp)`. ```php @@ -194,12 +194,12 @@ This will allow to use a non-standard namespace if front-end and back-end models ### Action Option -In this example, we will pass a `--action` option to set a custom path for the action column view. +In this example, we will use the `--action` option to set a custom path for the action column view. ``` php artisan datatables:make Posts --action="client.action" ``` -If not provided, a default path will be used. It will needs to be changed thereafter. +If no path is provided, a default path will be used. It will need to be changed thereafter. ### Columns Option @@ -208,13 +208,13 @@ In this example, we will pass a `--columns` option to set the columns to be used ``` php artisan datatables:make Posts --columns="id,title,author" ``` -If not provided, a default set of columns will be used. It will needs to be manually changed thereafter. +If not provided, a default set of columns will be used. It will need to be manually changed thereafter. ## Creating a DataTable Scope service class -DataTable scope is class that we can use to limit our database search results based on the defined query scopes. +DataTable scope is a class that we can use to limit our database search results based on the defined query scopes. ``` php artisan datatables:scope ActiveUser diff --git a/buttons-custom.md b/buttons-custom.md index 9330875..0f178ca 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -1,9 +1,9 @@ # Custom Actions -You can enable custom actions on your buttons, as follows: +You can enable custom actions on your buttons as follows: Update `UsersDataTable` class and overload the `actions` property. Here we are -disabling the `csv` and `pdf` action (so they cannot be fired by hijacking the +disabling the `csv` and `pdf` actions (so they cannot be fired by hijacking their request) and enabling a `myCustomAction`. From 689ab8688c3a72cedc49ed593b3a88ad1777b00d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Oct 2022 19:48:19 +0800 Subject: [PATCH 212/264] docs: use h2 & h3 --- quick-starter.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 85f03e7..8c7ddc3 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,26 +1,26 @@ -# DataTables Quick Starter +## DataTables Quick Starter -## Create a new Laravel project +### Create a new Laravel project ``` laravel new datatables cd datatables ``` -## Setup Laravel UI +### Setup Laravel UI ```shell composer require laravel/ui --dev php artisan ui bootstrap --auth ``` -## Install Laravel DataTables +### Install Laravel DataTables ```shell composer require yajra/laravel-datatables:^9.0 ``` -## Setup database and ENV configuration +### Setup database and ENV configuration Create a new database and update `.env` file and set the database credentials. @@ -37,7 +37,7 @@ DB_DATABASE=/absolute/path/to/database/database.sqlite php artisan migrate ``` -## Install Laravel DataTables Vite Assets +### Install Laravel DataTables Vite Assets ```shell npm i laravel-datatables-vite --save-dev @@ -49,7 +49,7 @@ This will install the following packages: 2. DataTables with Buttons and Select plugins for Bootstrap 5 3. Laravel DataTables custom scripts -## Register the package js and css +### Register the package js and css Edit `resources/js/app.js` and add the following: @@ -77,13 +77,13 @@ Edit `resources/sass/app.scss` and add the following: @import 'datatables.net-select-bs5/css/select.bootstrap5.css'; ``` -## Compile the assets +### Compile the assets ``` npm run dev ``` -## Create and update UsersDataTable +### Create and update UsersDataTable Create a new DataTable class: @@ -153,7 +153,7 @@ class UsersDataTable extends DataTable } ``` -## Create and update the users controller +### Create and update the users controller Create a new controller and add the following: @@ -175,7 +175,7 @@ class UsersController extends Controller } ``` -## Update the default app layout +### Update the default app layout Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app.blade.php` @@ -190,7 +190,7 @@ Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app. ``` -## Create users index file +### Create users index file Create new file: `resources/views/users/index.blade.php`. @@ -213,7 +213,7 @@ Create new file: `resources/views/users/index.blade.php`. @endpush ``` -## Register users route +### Register users route Update `routes/web.php`. @@ -223,7 +223,7 @@ use App\Http\Controllers\UsersController; Route::get('/users', [UsersController::class, 'index'])->name('users.index'); ``` -## Create dummy data using tinker +### Create dummy data using tinker ```php php artisan tinker @@ -232,7 +232,7 @@ Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman >>> User::factory(100)->create() ``` -## Access Users DataTables +### Access Users DataTables http://datatables.test/users From 09578ccdf0ea96395366de3bc9021299eb4f31c9 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 26 Oct 2022 19:57:05 +0800 Subject: [PATCH 213/264] Revert "docs: use h2 & h3" This reverts commit 689ab8688c3a72cedc49ed593b3a88ad1777b00d. --- quick-starter.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 8c7ddc3..85f03e7 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,26 +1,26 @@ -## DataTables Quick Starter +# DataTables Quick Starter -### Create a new Laravel project +## Create a new Laravel project ``` laravel new datatables cd datatables ``` -### Setup Laravel UI +## Setup Laravel UI ```shell composer require laravel/ui --dev php artisan ui bootstrap --auth ``` -### Install Laravel DataTables +## Install Laravel DataTables ```shell composer require yajra/laravel-datatables:^9.0 ``` -### Setup database and ENV configuration +## Setup database and ENV configuration Create a new database and update `.env` file and set the database credentials. @@ -37,7 +37,7 @@ DB_DATABASE=/absolute/path/to/database/database.sqlite php artisan migrate ``` -### Install Laravel DataTables Vite Assets +## Install Laravel DataTables Vite Assets ```shell npm i laravel-datatables-vite --save-dev @@ -49,7 +49,7 @@ This will install the following packages: 2. DataTables with Buttons and Select plugins for Bootstrap 5 3. Laravel DataTables custom scripts -### Register the package js and css +## Register the package js and css Edit `resources/js/app.js` and add the following: @@ -77,13 +77,13 @@ Edit `resources/sass/app.scss` and add the following: @import 'datatables.net-select-bs5/css/select.bootstrap5.css'; ``` -### Compile the assets +## Compile the assets ``` npm run dev ``` -### Create and update UsersDataTable +## Create and update UsersDataTable Create a new DataTable class: @@ -153,7 +153,7 @@ class UsersDataTable extends DataTable } ``` -### Create and update the users controller +## Create and update the users controller Create a new controller and add the following: @@ -175,7 +175,7 @@ class UsersController extends Controller } ``` -### Update the default app layout +## Update the default app layout Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app.blade.php` @@ -190,7 +190,7 @@ Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app. ``` -### Create users index file +## Create users index file Create new file: `resources/views/users/index.blade.php`. @@ -213,7 +213,7 @@ Create new file: `resources/views/users/index.blade.php`. @endpush ``` -### Register users route +## Register users route Update `routes/web.php`. @@ -223,7 +223,7 @@ use App\Http\Controllers\UsersController; Route::get('/users', [UsersController::class, 'index'])->name('users.index'); ``` -### Create dummy data using tinker +## Create dummy data using tinker ```php php artisan tinker @@ -232,7 +232,7 @@ Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman >>> User::factory(100)->create() ``` -### Access Users DataTables +## Access Users DataTables http://datatables.test/users From f4bc1d09df91b856374867fdbebdc238bbff2601 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 11:59:44 +0800 Subject: [PATCH 214/264] docs: remove some badge --- introduction.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/introduction.md b/introduction.md index fc30ba1..aaa9b08 100644 --- a/introduction.md +++ b/introduction.md @@ -20,13 +20,10 @@ Official documentation of DataTables is available at [datatables.net](https://da ## Laravel DataTables -[![Join the chat at https://gitter.im/yajra/laravel-datatables](https://badges.gitter.im/yajra/laravel-datatables.svg)](https://gitter.im/yajra/laravel-datatables?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![License](https://poser.pugx.org/yajra/laravel-datatables-oracle/license)](https://packagist.org/packages/yajra/laravel-datatables-oracle) -[![Laravel 4.2|5.x](https://img.shields.io/badge/Laravel-4.2|5.x-orange.svg)](http://laravel.com) [![Latest Stable Version](https://poser.pugx.org/yajra/laravel-datatables-oracle/v/stable)](https://packagist.org/packages/yajra/laravel-datatables-oracle) -[![Build Status](https://travis-ci.org/yajra/laravel-datatables.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/{{package}}/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/{{package}}/?branch=master) + [![Total Downloads](https://poser.pugx.org/yajra/laravel-datatables-oracle/downloads)](https://packagist.org/packages/yajra/laravel-datatables-oracle) Laravel DataTables is a package that handles the [server-side](https://www.datatables.net/manual/server-side) works of [DataTables](http://datatables.net) using [Laravel](http://laravel.com). From 83b8c1f6fc88bb49afa0e355e0aeff7e131cfc99 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 12:48:14 +0800 Subject: [PATCH 215/264] Update buttons-installation.md --- buttons-installation.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/buttons-installation.md b/buttons-installation.md index 424966c..438fafd 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -1,12 +1,19 @@ -# Buttons Plugin Installation +# Buttons Plugin -Github: https://github.com/yajra/laravel-datatables-buttons +A Laravel DataTables plugin for handling server-side exporting of table as csv, excel, pdf, etc. + + +## Installation Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-buttons:^9.0` +```shell +composer require yajra/laravel-datatables-buttons:^9.0 +``` + ## Configuration + > This step is optional if you are using Laravel 5.5 Open the file ```config/app.php``` and then add following service provider. @@ -21,6 +28,6 @@ Open the file ```config/app.php``` and then add following service provider. After completing the step above, use the following command to publish configuration & assets: -``` +```shell php artisan vendor:publish --tag=datatables-buttons ``` From 044a11ac884dbd77b9cac04e3b1ab88cd06ce5e7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 12:49:48 +0800 Subject: [PATCH 216/264] docs: 5.5+ --- buttons-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buttons-installation.md b/buttons-installation.md index 438fafd..839f35b 100644 --- a/buttons-installation.md +++ b/buttons-installation.md @@ -14,7 +14,7 @@ composer require yajra/laravel-datatables-buttons:^9.0 ## Configuration -> This step is optional if you are using Laravel 5.5 +> This step is optional if you are using Laravel 5.5+ Open the file ```config/app.php``` and then add following service provider. From 98c518e28a89e6f25d472ab3bfd1f6a888061552 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 12:52:20 +0800 Subject: [PATCH 217/264] docs: remove link to old tutz --- documentation.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/documentation.md b/documentation.md index 226ef6a..02896f0 100644 --- a/documentation.md +++ b/documentation.md @@ -5,14 +5,13 @@ - [Security Issues](/docs/{{package}}/{{version}}/security) - ## Getting Started - - [Introduction](/docs/{{package}}/{{version}}/introduction) - - [Installation](/docs/{{package}}/{{version}}/installation) + - [Introduction](/docs/{{package}}/{{version}}/introduction) + - [Installation](/docs/{{package}}/{{version}}/installation) - [Demo Application](https://datatables.yajrabox.com/) - [Community Links](/docs/{{package}}/{{version}}/community-links) - ## Tutorials - - [Quick Starter](/docs/{{package}}/{{version}}/quick-starter) - - [Service Implementation](https://datatables.yajrabox.com/service) + - [Quick Starter](/docs/{{package}}/{{version}}/quick-starter) - ## Configuration - [General Settings](/docs/{{package}}/{{version}}/general-settings) From a5608217bcb86b74167d0554a42dd19f64bc8e7f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 17:17:18 +0800 Subject: [PATCH 218/264] docs: bootcamp style quick starter --- quick-starter.md | 136 +++++++++++++++++++++++------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 85f03e7..5922ebf 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -1,43 +1,41 @@ -# DataTables Quick Starter +# Quick Starter -## Create a new Laravel project + +## 01. Installing Laravel & DataTables -``` +### Quick Installation + +If you have already installed [Laravel Installer](https://laravel.com/docs#your-first-laravel-project) on your local machine, you may create a new project via laravel command: + +```shell laravel new datatables -cd datatables ``` -## Setup Laravel UI +After the project has been created, we will then install [Laravel UI](https://github.com/laravel/ui) and [Yajra DataTables](https://github.com/yajra/laravel-datatables) ```shell +cd datatables + composer require laravel/ui --dev php artisan ui bootstrap --auth -``` - -## Install Laravel DataTables -```shell composer require yajra/laravel-datatables:^9.0 ``` -## Setup database and ENV configuration - -Create a new database and update `.env` file and set the database credentials. +For simplicity, you may use SQLite to store your application's data. To instruct Laravel to use SQLite instead of MySQL, update your new application's `.env` file and remove all of the `DB_*` environment variables except for the `DB_CONNECTION` variable, which should be set to `sqlite`: ```shell touch database/database.sqlite ``` -```dotenv +```dotenv filename=.env DB_CONNECTION=sqlite -DB_DATABASE=/absolute/path/to/database/database.sqlite ``` -```shell -php artisan migrate -``` + +## 02. Install Laravel DataTables Vite -## Install Laravel DataTables Vite Assets +Next, we will install [Laravel DataTables Vite](https://github.com/yajra/laravel-datatables-vite) to simplify our frontend setup. ```shell npm i laravel-datatables-vite --save-dev @@ -45,22 +43,20 @@ npm i laravel-datatables-vite --save-dev This will install the following packages: -1. Bootstrap Icons -2. DataTables with Buttons and Select plugins for Bootstrap 5 -3. Laravel DataTables custom scripts - -## Register the package js and css +``` + - Bootstrap Icons + - DataTables with Buttons and Select plugins for Bootstrap 5 + - Laravel DataTables custom scripts +``` -Edit `resources/js/app.js` and add the following: +Once installed, we can now configure our scripts and css needed for our application. -```js +```js filename=resources/js/app.js import './bootstrap'; import 'laravel-datatables-vite'; ``` -Edit `resources/sass/app.scss` and add the following: - -```postcss +```postcss filename=resources/sass/app.scss // Fonts @import url('https://fonts.bunny.net/css?family=Nunito'); @@ -77,23 +73,24 @@ Edit `resources/sass/app.scss` and add the following: @import 'datatables.net-select-bs5/css/select.bootstrap5.css'; ``` -## Compile the assets +We just need to start the Vite development server to automatically recompile our JS, CSS and refresh the browser when we make changes to our Blade templates: -``` +```shell npm run dev ``` -## Create and update UsersDataTable + +## 03. Setup a Users DataTable -Create a new DataTable class: +Open a new terminal in your `datatables` project directory and run the following command: ```shell php artisan datatables:make Users ``` -Then, update the `getColumns()` with the users fields: +Next, we will configure our `UsersDataTable` and add the columns that we want to display. -```php +```php filename=app/DataTables/UsersDataTable.php namespace App\DataTables; use App\Models\User; @@ -135,7 +132,7 @@ class UsersDataTable extends DataTable ]); } - protected function getColumns(): array + public function getColumns(): array { return [ Column::make('id'), @@ -153,15 +150,14 @@ class UsersDataTable extends DataTable } ``` -## Create and update the users controller - -Create a new controller and add the following: + +## 04. Setup a Users Controller, View & Route ```shell php artisan make:controller UsersController ``` -```php +```php filename=app/Http/Controllers/UsersController.php namespace App\Http\Controllers; use App\DataTables\UsersDataTable; @@ -175,26 +171,7 @@ class UsersController extends Controller } ``` -## Update the default app layout - -Add `@stack('scripts')` before the body end tag of `resources/views/layouts/app.blade.php` - -``` -.... -
- @yield('content') -
- - @stack('scripts') - - -``` - -## Create users index file - -Create new file: `resources/views/users/index.blade.php`. - -```php +```blade filename=resources/views/users/index.blade.php @extends('layouts.app') @section('content') @@ -213,26 +190,49 @@ Create new file: `resources/views/users/index.blade.php`. @endpush ``` -## Register users route - -Update `routes/web.php`. - -```php +```php filename=routes/web.php use App\Http\Controllers\UsersController; Route::get('/users', [UsersController::class, 'index'])->name('users.index'); ``` -## Create dummy data using tinker + +## 05. Update the default app layout -```php +To be able to load our custom scripts, we need to add `@stack('scripts')` before the end of `body` tag in our `app.blade.php` layout. + +```blade filename=resources/views/layouts/app.blade.php +.... +
+ @yield('content') +
+ + @stack('scripts') + + +``` + + +## 06. Migrate and Seed Test Data + +```shell +php artisan migrate php artisan tinker +``` +```php Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman >>> User::factory(100)->create() ``` -## Access Users DataTables +Our application should now be ready to run. + +```shell +php artisan serve +``` + +Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000]([http://localhost:8000). -http://datatables.test/users +We can now visit our [`/users`](http://localhost:8000/users) via route and see our users table. +Laravel DataTables Users From 29fab38c39990ada63b5fa655a3703857e26033d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 17:50:27 +0800 Subject: [PATCH 219/264] fix: typo --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 5922ebf..1f8fb34 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -233,6 +233,6 @@ php artisan serve Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000]([http://localhost:8000). -We can now visit our [`/users`](http://localhost:8000/users) via route and see our users table. +We can now visit our [`/users`](http://localhost:8000/users) route and see our users table. Laravel DataTables Users From 0f51be95f03a917ad256851cc0144d7472e81f70 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 17:54:00 +0800 Subject: [PATCH 220/264] use image from site --- quick-starter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quick-starter.md b/quick-starter.md index 1f8fb34..e911865 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -233,6 +233,6 @@ php artisan serve Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000]([http://localhost:8000). -We can now visit our [`/users`](http://localhost:8000/users) route and see our users table. +We can now visit our [`/users`](http://localhost:8000/users) via route and see our users table. -Laravel DataTables Users +Laravel DataTables Users From 6f945e88d961a56c4caed50a0ced777499cfcf76 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 17:58:37 +0800 Subject: [PATCH 221/264] Update documentation.md --- documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation.md b/documentation.md index 02896f0..c1160d4 100644 --- a/documentation.md +++ b/documentation.md @@ -77,7 +77,7 @@ ### PLUGINS -- ## HTML Builder +- ## Html - [Installation](/docs/{{package}}/{{version}}/html-installation) - [Builder](/docs/{{package}}/{{version}}/html-builder) - [Table](/docs/{{package}}/{{version}}/html-builder-table) From 0a4795817c7a8a5320dcdc6f31d8ef429970f902 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 18:03:18 +0800 Subject: [PATCH 222/264] typo --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index e911865..7e96d71 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -233,6 +233,6 @@ php artisan serve Once you have started the Artisan development server, your application will be accessible in your web browser at [http://localhost:8000]([http://localhost:8000). -We can now visit our [`/users`](http://localhost:8000/users) via route and see our users table. +We can now visit our [`/users`](http://localhost:8000/users) route and see our users table. Laravel DataTables Users From 9832eaa53b62c524d33abc090bf1b3ab054c4a8f Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 18:40:36 +0800 Subject: [PATCH 223/264] Update search-panes-starter.md --- search-panes-starter.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/search-panes-starter.md b/search-panes-starter.md index a9c96e9..9385858 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -5,11 +5,13 @@ allow the user to quickly filter the datatable after predefined filters. > {note} To use datatables you need to make sure that the npm packages `datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are installed and added to your `app.js`/`app.css` files. + ## Adding SearchPanes to the frontend To be able to see SearchPanes you need to either add them fixed in the dom (displayed at all time) or add a button which opens them as popup. + ### Adding SearchPanes fixed in the dom SearchPanes can be added to a table via the dom string, in it, they are marked with a `P` if you for example @@ -17,6 +19,7 @@ are using `Bfrtip` as dom you can use `PBfrtip` to display the SearchPanes at th to display them at the very bottom. Setting the dom String with the `\Yajra\DataTables\Html\Builder`: + ```php public function html() : \Yajra\DataTables\Html\Builder { @@ -34,6 +37,7 @@ public function html() : \Yajra\DataTables\Html\Builder } ``` + ### Adding SearchPanes with a button To add a button which opens the SearchPanes you need to make one extending `searchPanes`: @@ -58,6 +62,7 @@ public function html() : \Yajra\DataTables\Html\Builder } ``` + ## Adding SearchPanes to the backend The SearchPanes can be filled in the datatables declaration via the `searchPane()` method. The method takes the column From 3f40edc63960a55ce2764187afc3547e7ada1070 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 18:42:29 +0800 Subject: [PATCH 224/264] Update search-panes-starter.md --- search-panes-starter.md | 1 - 1 file changed, 1 deletion(-) diff --git a/search-panes-starter.md b/search-panes-starter.md index 9385858..55f09e3 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -5,7 +5,6 @@ allow the user to quickly filter the datatable after predefined filters. > {note} To use datatables you need to make sure that the npm packages `datatables.net-select-bs4` and `datatables.net-searchpanes-bs4` are installed and added to your `app.js`/`app.css` files. - ## Adding SearchPanes to the frontend To be able to see SearchPanes you need to either add them fixed in the dom (displayed at all time) or add a button which From 4a34b91b78b71f3839f73cc070c29569a4288557 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 18:44:40 +0800 Subject: [PATCH 225/264] remove demo app link --- documentation.md | 1 - 1 file changed, 1 deletion(-) diff --git a/documentation.md b/documentation.md index c1160d4..206ceba 100644 --- a/documentation.md +++ b/documentation.md @@ -7,7 +7,6 @@ - ## Getting Started - [Introduction](/docs/{{package}}/{{version}}/introduction) - [Installation](/docs/{{package}}/{{version}}/installation) - - [Demo Application](https://datatables.yajrabox.com/) - [Community Links](/docs/{{package}}/{{version}}/community-links) - ## Tutorials From 181c41d997f61651d9332753e14ff61455a2a18a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 18:49:55 +0800 Subject: [PATCH 226/264] Update response-array.md --- response-array.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/response-array.md b/response-array.md index 59270ee..aa73ff1 100644 --- a/response-array.md +++ b/response-array.md @@ -1,6 +1,6 @@ # Array Response -Array response is the default response of DataTables. +The default response of the package is an array of objects. If you prefer to return an array response, use `make(false)`. ```php use DataTables; @@ -10,7 +10,7 @@ Route::get('user-data', function() { return DataTables::eloquent($model) ->addColumn('intro', 'Hi {{$name}}!') - ->make(); + ->make(false); }); ``` From d36787f2b5da1c7e498c239b4b3848c4405ab4e3 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 19:01:18 +0800 Subject: [PATCH 227/264] Update html-builder.md --- html-builder.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/html-builder.md b/html-builder.md index 7faf9c1..a39d6de 100644 --- a/html-builder.md +++ b/html-builder.md @@ -11,6 +11,7 @@ You can use the `Builder` class by using Dependency Injection. use Yajra\DataTables\Html\Builder; Route::get('users', function(Builder $builder) { + // }); ``` @@ -37,9 +38,10 @@ Route::get('users', function(DataTables $dataTable) { ## Html Builder Example -```php +```php filename=routes/web.php use DataTables; use Yajra\DataTables\Html\Builder; +use Yajra\DataTables\Html\Column; Route::get('users', function(Builder $builder) { if (request()->ajax()) { @@ -47,27 +49,26 @@ Route::get('users', function(Builder $builder) { } $html = $builder->columns([ - ['data' => 'id', 'name' => 'id', 'title' => 'Id'], - ['data' => 'name', 'name' => 'name', 'title' => 'Name'], - ['data' => 'email', 'name' => 'email', 'title' => 'Email'], - ['data' => 'created_at', 'name' => 'created_at', 'title' => 'Created At'], - ['data' => 'updated_at', 'name' => 'updated_at', 'title' => 'Updated At'], + Column::make('id), + Column::make('name), + Column::make('email), + Column::make('created_at), + Column::make('updated_at), ]); return view('users.index', compact('html')); }); ``` -On your `resources/views/users/index.blade.php`. -```php +```php filename=resources/views/users/index.blade.php @extends('app') @section('contents') - {!! $html->table() !!} + {{ $html->table() }} @endsection @push('scripts') - {!! $html->scripts() !!} + {{ $html->scripts() }} @endpush ``` From 01be62e252bbafe361c274004ecb7179e2540f63 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 27 Oct 2022 19:05:01 +0800 Subject: [PATCH 228/264] Update html-builder.md --- html-builder.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/html-builder.md b/html-builder.md index a39d6de..4339798 100644 --- a/html-builder.md +++ b/html-builder.md @@ -39,24 +39,25 @@ Route::get('users', function(DataTables $dataTable) { ## Html Builder Example ```php filename=routes/web.php -use DataTables; +use Yajra\DataTables\Facades\DataTables; use Yajra\DataTables\Html\Builder; use Yajra\DataTables\Html\Column; +use App\Models\User; Route::get('users', function(Builder $builder) { - if (request()->ajax()) { + if (request()->ajax()) { return DataTables::of(User::query())->toJson(); } - $html = $builder->columns([ - Column::make('id), - Column::make('name), - Column::make('email), - Column::make('created_at), - Column::make('updated_at), - ]); + $html = $builder->columns([ + Column::make('id'), + Column::make('name'), + Column::make('email'), + Column::make('created_at'), + Column::make('updated_at'), + ]); - return view('users.index', compact('html')); + return view('users.index', compact('html')); }); ``` From b5b423ab18fa580fa3526656a7b8045609d36cf9 Mon Sep 17 00:00:00 2001 From: Emmanuel Joseph Beron Date: Thu, 27 Oct 2022 23:48:34 +0800 Subject: [PATCH 229/264] Fix typo --- engine-eloquent.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine-eloquent.md b/engine-eloquent.md index e2874c9..f68e4d0 100644 --- a/engine-eloquent.md +++ b/engine-eloquent.md @@ -1,7 +1,7 @@ # Eloquent Data Source You may use Laravel's Eloquent Model as data source for your dataTables. -You can look at `Yajra\DataTables\EloquentDataTable` class which handles the conversion of your Eloquent Model into a readbale DataTable API response. +You can look at `Yajra\DataTables\EloquentDataTable` class which handles the conversion of your Eloquent Model into a readable DataTable API response. ## Eloquent via Factory From f21ba2e56950cc90123e0938b994fcfaec0afe44 Mon Sep 17 00:00:00 2001 From: Emmanuel Joseph Beron Date: Thu, 27 Oct 2022 23:49:07 +0800 Subject: [PATCH 230/264] Fix typo --- engine-collection.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine-collection.md b/engine-collection.md index 3b8bed0..418ccc4 100644 --- a/engine-collection.md +++ b/engine-collection.md @@ -1,7 +1,7 @@ # Collection Data Source You may use Laravel's Collection as data source for your dataTables. -You can look at `Yajra\DataTables\CollectionDataTable` class which handles the conversion of your Collection into a readbale DataTable API response. +You can look at `Yajra\DataTables\CollectionDataTable` class which handles the conversion of your Collection into a readable DataTable API response. ## Collection via Factory From e024fbfb8e4c2ba624f3788977141facc2e43faa Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 3 Nov 2022 13:06:08 +0800 Subject: [PATCH 231/264] Update search-panes-starter.md --- search-panes-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/search-panes-starter.md b/search-panes-starter.md index 55f09e3..969e947 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -1,4 +1,4 @@ -# Add SearchPane +# SearchPanes Extension [SearchPanes](https://datatables.net/extensions/searchpanes/) ([example](https://datatables.net/extensions/searchpanes/examples/initialisation/simple.html)) allow the user to quickly filter the datatable after predefined filters. From a542888d5b8c4382df2101cf53fc660588e75927 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 3 Nov 2022 13:06:59 +0800 Subject: [PATCH 232/264] Update documentation.md --- documentation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation.md b/documentation.md index 206ceba..14788f5 100644 --- a/documentation.md +++ b/documentation.md @@ -61,7 +61,7 @@ - [Order By Nulls Last](/docs/{{package}}/{{version}}/order-by-nulls-last) - ## SearchPanes - - [Add SearchPanes](/docs/{{package}}/{{version}}/search-panes-starter) + - [SearchPanes Extension](/docs/{{package}}/{{version}}/search-panes-starter) - [Hide Columns in SearchPanes](/docs/{{package}}/{{version}}/search-panes-hide-columns) - [Further options](/docs/{{package}}/{{version}}/search-panes-options) From 178e1c04c762cb30e2bf4bff3c11c49f73bdc3ce Mon Sep 17 00:00:00 2001 From: Arne Perschke Date: Sat, 14 Jan 2023 13:26:52 +0100 Subject: [PATCH 233/264] Tweaked SearchPanes chapter titles --- search-panes-hide-columns.md | 2 +- search-panes-starter.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/search-panes-hide-columns.md b/search-panes-hide-columns.md index 3064861..9d51f67 100644 --- a/search-panes-hide-columns.md +++ b/search-panes-hide-columns.md @@ -1,4 +1,4 @@ -# Hide Columns in SearchPanes +# Exclude Columns Some columns you might not want in your SearchPanes, to hide them you can add `->searchPanes(false)` in your column definition: diff --git a/search-panes-starter.md b/search-panes-starter.md index 969e947..c363b22 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -1,4 +1,4 @@ -# SearchPanes Extension +# Getting Started [SearchPanes](https://datatables.net/extensions/searchpanes/) ([example](https://datatables.net/extensions/searchpanes/examples/initialisation/simple.html)) allow the user to quickly filter the datatable after predefined filters. From dfbf5456b01bddd092cabbdf922722e9159aa702 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 20 Feb 2023 15:32:22 +0800 Subject: [PATCH 234/264] Update installation.md --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 2db07f1..95e7af2 100644 --- a/installation.md +++ b/installation.md @@ -28,7 +28,7 @@ composer require yajra/laravel-datatables-oracle:"^10.0" If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. ```bash -composer require yajra/laravel-datatables:^9.0 +composer require yajra/laravel-datatables:^10.0 ``` From 20aa69eb46ae4cb750b81a878e62f7bb9da78f2e Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 20 Feb 2023 20:15:28 +0800 Subject: [PATCH 235/264] docs: remove package version --- quick-starter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quick-starter.md b/quick-starter.md index 7e96d71..fe09e60 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -19,7 +19,7 @@ cd datatables composer require laravel/ui --dev php artisan ui bootstrap --auth -composer require yajra/laravel-datatables:^9.0 +composer require yajra/laravel-datatables ``` For simplicity, you may use SQLite to store your application's data. To instruct Laravel to use SQLite instead of MySQL, update your new application's `.env` file and remove all of the `DB_*` environment variables except for the `DB_CONNECTION` variable, which should be set to `sqlite`: From 79bda837512eeca782b898572cd911f4ea472324 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 20 Feb 2023 23:47:09 +0800 Subject: [PATCH 236/264] docs: laravel 10 + vitejs setup --- editor-tutorial.md | 173 +++++++++++++++++++++++++++++---------------- 1 file changed, 113 insertions(+), 60 deletions(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index cf453b2..f12d42b 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -5,11 +5,13 @@ See [DataTables Editor](https://editor.datatables.net/purchase/index) for detail ## Pre-requisites -This tutorial requires https://yajrabox.com/docs/laravel-datatables/master/quick-starter. +This tutorial requires https://yajrabox.com/docs/laravel-datatables/10.0/quick-starter. ## Install DataTables Editor assets. - yarn add datatables.net-editor datatables.net-editor-bs4 datatables.net-select-bs4 +```sh +npm i datatables.net-editor datatables.net-editor-bs5 +``` ## Editor License @@ -17,107 +19,158 @@ Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project fold ## Register postinstall script to package.json +```json "scripts": { - "postinstall": "node ./node_modules/datatables.net-editor/install.js ./Editor.zip", - "dev": "npm run development", - ..... + "dev": "vite", + "build": "vite build", + "postinstall": "node node_modules/datatables.net-editor/install.js ./Editor.zip" }, +``` -## Register editor script on `resources/js/bootstrap.js` - - try { - window.Popper = require('popper.js').default; - window.$ = window.jQuery = require('jquery'); +## Register editor script on `resources/js/app.js` - require('bootstrap'); - require('datatables.net-bs4'); - require('datatables.net-buttons-bs4'); - require('datatables.net-select-bs4'); - require('datatables.net-editor-bs4'); - } catch (e) {} +```js +import './bootstrap'; +import 'laravel-datatables-vite'; +import "datatables.net-editor"; +import Editor from "datatables.net-editor-bs5"; +Editor(window, $); +``` ## Add editor styles on `resources/sass/app.scss`. - @import "~datatables.net-select-bs4/css/select.bootstrap4.css"; - @import "~datatables.net-editor-bs4/css/editor.bootstrap4.css"; - -## Recompile assets. +```css +// Fonts +@import url('https://fonts.bunny.net/css?family=Nunito'); - yarn - yarn watch / dev / prod +// Variables +@import 'variables'; +// Bootstrap +@import 'bootstrap/scss/bootstrap'; -## Update UsersDataTable and register the Editor buttons. - -> Note: CREATE button is in conflict with `buttons.server-side.js`. You need to remove the create button or rename it to something else like `add` button. - - DataTable.ext.buttons.add = { - className: 'buttons-add', +// DataTables +@import 'bootstrap-icons/font/bootstrap-icons.css'; +@import "datatables.net-bs5/css/dataTables.bootstrap5.css"; +@import "datatables.net-buttons-bs5/css/buttons.bootstrap5.css"; +@import "datatables.net-editor-bs5/css/editor.bootstrap5.css"; +@import 'datatables.net-select-bs5/css/select.bootstrap5.css'; +``` - text: function (dt) { - return ' ' + dt.i18n('buttons.add', 'Create'); - }, +## Recompile assets. - action: function (e, dt, button, config) { - window.location = window.location.href.replace(/\/+$/, "") + '/create'; - } - }; +```sh +npm run dev +``` ### UsersDataTable.php Create a new editor instance and add some fields for name and email. ```php +namespace App\DataTables; + +use App\Models\User; +use Illuminate\Database\Eloquent\Builder as QueryBuilder; +use Yajra\DataTables\EloquentDataTable; +use Yajra\DataTables\Html\Builder as HtmlBuilder; +use Yajra\DataTables\Html\Button; +use Yajra\DataTables\Html\Column; use Yajra\DataTables\Html\Editor\Editor; use Yajra\DataTables\Html\Editor\Fields; +use Yajra\DataTables\Services\DataTable; -... +class UsersDataTable extends DataTable +{ /** * Build DataTable class. * - * @param mixed $query Results from query() method. - * @return \Yajra\DataTables\DataTableAbstract + * @param QueryBuilder $query Results from query() method. + * @return \Yajra\DataTables\EloquentDataTable + */ + public function dataTable(QueryBuilder $query): EloquentDataTable + { + return (new EloquentDataTable($query)) + ->addColumn('action', 'users.action') + ->setRowId('id'); + } + + /** + * Get query source of dataTable. + * + * @param \App\Models\User $model + * @return \Illuminate\Database\Eloquent\Builder */ - public function dataTable($query) + public function query(User $model): QueryBuilder { - return datatables() - ->eloquent($query) - ->setRowId('id') // Set the RowID - ... + return $model->newQuery(); } - public function html() + /** + * Optional method if you want to use html builder. + * + * @return \Yajra\DataTables\Html\Builder + */ + public function html(): HtmlBuilder { return $this->builder() ->setTableId('users-table') ->columns($this->getColumns()) ->minifiedAjax() - ->dom('Bfrtip') ->orderBy(1) - ->buttons( + ->selectStyleSingle() + ->editors([ + Editor::make() + ->fields([ + Fields\Text::make('name'), + Fields\Text::make('email'), + ]), + ]) + ->buttons([ Button::make('create')->editor('editor'), Button::make('edit')->editor('editor'), Button::make('remove')->editor('editor'), - Button::make('export'), + Button::make('excel'), + Button::make('csv'), + Button::make('pdf'), Button::make('print'), Button::make('reset'), - Button::make('reload') - ) - ->editor( - Editor::make() - ->fields([ - Fields\Text::make('name'), - Fields\Text::make('email'), - Fields\Password::make('password'), - ]) - ); + Button::make('reload'), + ]); + } + + /** + * Get the dataTable columns definition. + * + * @return array + */ + public function getColumns(): array + { + return [ + Column::make('id'), + Column::make('name'), + Column::make('email'), + Column::make('created_at'), + Column::make('updated_at'), + ]; + } + + /** + * Get filename for export. + * + * @return string + */ + protected function filename(): string + { + return 'Users_'.date('YmdHis'); } +} ``` ## Create Editor Class to handle CRUD actions. -``` +```sh php artisan datatables:editor Users ``` @@ -125,13 +178,13 @@ php artisan datatables:editor Users Edit `routes/web.php` and register the store user route. -``` +```php Route::post('/users', 'UsersController@store')->name('users.store'); ``` ## Update users controller -``` +```php namespace App\Http\Controllers; use Illuminate\Http\Request; From 94bd5300d3d977b0ca885abd98197c14bebdc0dc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Mon, 20 Feb 2023 23:55:23 +0800 Subject: [PATCH 237/264] fix: route --- editor-tutorial.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index f12d42b..fdcc56b 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -179,7 +179,8 @@ php artisan datatables:editor Users Edit `routes/web.php` and register the store user route. ```php -Route::post('/users', 'UsersController@store')->name('users.store'); +Route::get('/users', [App\Http\Controllers\UsersController::class, 'index'])->name('users.index'); +Route::post('/users', [App\Http\Controllers\UsersController::class, 'store'])->name('users.store'); ``` ## Update users controller From bfed2fdbdbf920ef0906a9201007fb2b61f3d46b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Feb 2023 00:23:30 +0800 Subject: [PATCH 238/264] docs: add postinstall first --- editor-tutorial.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index fdcc56b..94d7aad 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -7,12 +7,6 @@ See [DataTables Editor](https://editor.datatables.net/purchase/index) for detail This tutorial requires https://yajrabox.com/docs/laravel-datatables/10.0/quick-starter. -## Install DataTables Editor assets. - -```sh -npm i datatables.net-editor datatables.net-editor-bs5 -``` - ## Editor License Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project folder. @@ -27,6 +21,12 @@ Copy and rename your `Editor.XX.zip` to `Editor.zip` and move it to project fold }, ``` +## Install DataTables Editor assets. + +```sh +npm i datatables.net-editor datatables.net-editor-bs5 +``` + ## Register editor script on `resources/js/app.js` ```js From 944538f984a439f5f2b503ddd41231c3770c84be Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Feb 2023 00:25:08 +0800 Subject: [PATCH 239/264] docs: shorter title --- editor-tutorial.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/editor-tutorial.md b/editor-tutorial.md index 94d7aad..caff59b 100644 --- a/editor-tutorial.md +++ b/editor-tutorial.md @@ -1,4 +1,4 @@ -# Creating a Laravel Full CRUD with DataTables Editor. +# Laravel 10 CRUD with DataTables Editor. Before we begin, please be reminded that the Editor library that we are going to use here requires a paid license. See [DataTables Editor](https://editor.datatables.net/purchase/index) for details. @@ -91,9 +91,7 @@ class UsersDataTable extends DataTable */ public function dataTable(QueryBuilder $query): EloquentDataTable { - return (new EloquentDataTable($query)) - ->addColumn('action', 'users.action') - ->setRowId('id'); + return (new EloquentDataTable($query))->setRowId('id'); } /** From a65a0b63fb4c2bab34a13ac3a3024eed6e20d6ce Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Feb 2023 12:29:00 +0800 Subject: [PATCH 240/264] docs: laravel 9 & 10 install docs --- installation.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/installation.md b/installation.md index 95e7af2..83c15e8 100644 --- a/installation.md +++ b/installation.md @@ -11,7 +11,7 @@ ### Requirements -- [Laravel 9+](https://github.com/laravel/framework) +- [Laravel 9|10](https://github.com/laravel/framework) - [jQuery DataTables v1.10.x](http://datatables.net/) @@ -21,6 +21,14 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: +#### Laravel 9 + +```bash +composer require yajra/laravel-datatables-oracle:"^9.0" +``` + +#### Laravel 10 + ```bash composer require yajra/laravel-datatables-oracle:"^10.0" ``` From 39150e363c354df30161c214661e09473592380d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Feb 2023 12:30:18 +0800 Subject: [PATCH 241/264] docs: fix installer --- installation.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/installation.md b/installation.md index 83c15e8..e24f5c0 100644 --- a/installation.md +++ b/installation.md @@ -21,19 +21,19 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: -#### Laravel 9 - ```bash -composer require yajra/laravel-datatables-oracle:"^9.0" +composer require yajra/laravel-datatables-oracle:"^10.0" ``` -#### Laravel 10 +If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. + +#### Laravel 9 ```bash -composer require yajra/laravel-datatables-oracle:"^10.0" +composer require yajra/laravel-datatables:"^9.0" ``` -If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. +#### Laravel 10 ```bash composer require yajra/laravel-datatables:^10.0 From 0519c597676f846286f5d43bdaf1f0ea7faf60c9 Mon Sep 17 00:00:00 2001 From: raulmainlab <123628611+raulmainlab@users.noreply.github.com> Date: Wed, 1 Mar 2023 10:43:59 +0100 Subject: [PATCH 242/264] Update html-builder-column-builder.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit questa è la proposta giusta per rendere eseguibile il codice da html builder Column Builder --- html-builder-column-builder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-column-builder.md b/html-builder-column-builder.md index b523cb0..d7df80a 100644 --- a/html-builder-column-builder.md +++ b/html-builder-column-builder.md @@ -30,7 +30,7 @@ $column = Column::make('id') ->title('Id') ->searchable(true) ->orderable(true) - ->render('function(){}') + ->render('\'
\' + (full[\'deleted_at\'] == null ? \'Attivo\' : \'Disattivo\') + \'
\';\'\'' ) ->footer('Id') ->exportable(true) ->printable(true); From 13a0599349ce70f0619f5c95feeeec859652209a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 16 Mar 2023 10:43:44 +0800 Subject: [PATCH 243/264] docs: Builder::useVite() helper --- quick-starter.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/quick-starter.md b/quick-starter.md index fe09e60..15b1c7b 100644 --- a/quick-starter.md +++ b/quick-starter.md @@ -196,6 +196,34 @@ use App\Http\Controllers\UsersController; Route::get('/users', [UsersController::class, 'index'])->name('users.index'); ``` +### Use ViteJs / script type defaults to module + +You can also set DataTable to use vitejs by default by registering `Builder::useVite()` inside the `AppServiceProvider`. + +```php +namespace App\Providers; + +use Illuminate\Support\ServiceProvider; +use Yajra\DataTables\Html\Builder; + +class AppServiceProvider extends ServiceProvider +{ + public function boot(): void + { + Builder::useVite(); + } +} +``` + +Upon registering, you can now use scripts and without the need to set the type to module. + +```php +@push('scripts') + {{ $dataTable->scripts() }} +@endpush +``` + + ## 05. Update the default app layout From 04f0bc23547a86b6f72369297a6be18cb1ba36f8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 21 Mar 2023 09:43:33 +0800 Subject: [PATCH 244/264] docs: use latest version constraint fix: https://github.com/yajra/laravel-datatables/issues/2969 --- installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installation.md b/installation.md index e24f5c0..992bbba 100644 --- a/installation.md +++ b/installation.md @@ -22,7 +22,7 @@ Laravel DataTables can be installed with [Composer](http://getcomposer.org/doc/0 Run the following command in your project to get the latest version of the package: ```bash -composer require yajra/laravel-datatables-oracle:"^10.0" +composer require yajra/laravel-datatables-oracle:"^10.3.1" ``` If you are using most of the DataTables plugins like Buttons & Html, you can alternatively use the all-in-one installer package. From f2adb9ee84178c563fc6a8725d3483b2287b3ef7 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 24 Mar 2023 11:39:31 +0800 Subject: [PATCH 245/264] docs: add actions property type fix https://github.com/yajra/laravel-datatables/issues/2973 --- buttons-custom.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/buttons-custom.md b/buttons-custom.md index 0f178ca..714faec 100644 --- a/buttons-custom.md +++ b/buttons-custom.md @@ -15,15 +15,17 @@ use Yajra\DataTables\Services\DataTable; class UsersDataTable extends DataTable { - protected $actions = ['print', 'excel', 'myCustomAction']; + protected array $actions = ['print', 'excel', 'myCustomAction']; public function html() { return $this->builder() ->columns($this->getColumns()) - ->parameters([ - 'dom' => 'Bfrtip', - 'buttons' => ['print', 'excel', 'myCustomAction'], + ->dom('Bfrtip') + ->buttons([ + 'print', + 'excel', + 'myCustomAction', ]); } From 6a1823d54132935fabd1af8ac0d0047e73ef246d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 29 Mar 2023 13:10:57 +0800 Subject: [PATCH 246/264] docs: update generated service class --- buttons-console.md | 155 ++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 109 deletions(-) diff --git a/buttons-console.md b/buttons-console.md index 0efc0fc..478ffcc 100644 --- a/buttons-console.md +++ b/buttons-console.md @@ -23,72 +23,84 @@ This will create a `PostsDataTable` class in the `app\DataTables` directory. ```php namespace App\DataTables; -use App\User; +use App\Models\Post; +use Illuminate\Database\Eloquent\Builder as QueryBuilder; +use Yajra\DataTables\EloquentDataTable; +use Yajra\DataTables\Html\Builder as HtmlBuilder; +use Yajra\DataTables\Html\Button; +use Yajra\DataTables\Html\Column; +use Yajra\DataTables\Html\Editor\Editor; +use Yajra\DataTables\Html\Editor\Fields; use Yajra\DataTables\Services\DataTable; class PostsDataTable extends DataTable { /** - * Build DataTable class. + * Build the DataTable class. * - * @return \Yajra\DataTables\DataTableAbstract + * @param QueryBuilder $query Results from query() method. */ - public function dataTable() + public function dataTable(QueryBuilder $query): EloquentDataTable { - return $this->datatables - ->eloquent($this->query()) - ->addColumn('action', 'path.to.action.view'); + return (new EloquentDataTable($query)) + ->addColumn('action', 'posts.action') + ->setRowId('id'); } /** - * Get the query object to be processed by dataTables. - * - * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection + * Get the query source of dataTable. */ - public function query() + public function query(Post $model): QueryBuilder { - $query = User::query(); - - return $this->applyScopes($query); + return $model->newQuery(); } /** - * Optional method if you want to use html builder. - * - * @return \Yajra\DataTables\Html\Builder + * Optional method if you want to use the html builder. */ - public function html() + public function html(): HtmlBuilder { return $this->builder() + ->setTableId('posts-table') ->columns($this->getColumns()) - ->ajax('') - ->addAction(['width' => '80px']) - ->parameters($this->getBuilderParameters()); + ->minifiedAjax() + //->dom('Bfrtip') + ->orderBy(1) + ->selectStyleSingle() + ->buttons([ + Button::make('excel'), + Button::make('csv'), + Button::make('pdf'), + Button::make('print'), + Button::make('reset'), + Button::make('reload') + ]); } /** - * Get columns. - * - * @return array + * Get the dataTable columns definition. */ - protected function getColumns() + public function getColumns(): array { return [ - 'id', - // add your columns - 'created_at', - 'updated_at', + Column::computed('action') + ->exportable(false) + ->printable(false) + ->width(60) + ->addClass('text-center'), + Column::make('id'), + Column::make('add your columns'), + Column::make('created_at'), + Column::make('updated_at'), ]; } /** - * Get filename for export. - * - * @return string + * Get the filename for export. */ - protected function filename() + protected function filename(): string { - return 'posts_' . time(); + return 'Posts_' . date('YmdHis'); } } ``` @@ -104,81 +116,6 @@ php artisan datatables:make Posts --model This will generate an `App\DataTables\PostsDataTable` class that uses `App\Post` as the base model for our query. The exported filename will also be set to `posts_(timestamp)`. -```php -datatables - ->eloquent($this->query()) - ->addColumn('action', 'path.to.action.view'); - } - - /** - * Get the query object to be processed by dataTables. - * - * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder|\Illuminate\Support\Collection - */ - public function query() - { - $query = Post::query(); - - return $this->applyScopes($query); - } - - /** - * Optional method if you want to use html builder. - * - * @return \Yajra\DataTables\Html\Builder - */ - public function html() - { - return $this->builder() - ->columns($this->getColumns()) - ->ajax('') - ->addAction(['width' => '80px']) - ->parameters($this->getBuilderParameters()); - } - - /** - * Get columns. - * - * @return array - */ - protected function getColumns() - { - return [ - 'id', - // add your columns - 'created_at', - 'updated_at', - ]; - } - - /** - * Get filename for export. - * - * @return string - */ - protected function filename() - { - return 'posts_' . time(); - } -} -``` - ### Model Namespace Option From bd93c8d28bdfa2156ba0c5809e3b6f1838ed3453 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Sat, 15 Apr 2023 08:32:10 +0800 Subject: [PATCH 247/264] chore: use English --- html-builder-column-builder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-column-builder.md b/html-builder-column-builder.md index d7df80a..1f1fd6e 100644 --- a/html-builder-column-builder.md +++ b/html-builder-column-builder.md @@ -30,7 +30,7 @@ $column = Column::make('id') ->title('Id') ->searchable(true) ->orderable(true) - ->render('\'
\' + (full[\'deleted_at\'] == null ? \'Attivo\' : \'Disattivo\') + \'
\';\'\'' ) + ->render('\'
\' + (full[\'deleted_at\'] == null ? \'Active\' : \'Inactive\') + \'
\';\'\'' ) ->footer('Id') ->exportable(true) ->printable(true); From a54b46964b81489bd6d4d18b10854b62f3003509 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Golestan Date: Sun, 7 May 2023 12:22:14 +0330 Subject: [PATCH 248/264] add exportRender how to use to document (this method added on commit d48dc1bbe8bc860070240d6f1444e7a861c53789 to be used for render column for print or export as we expected) --- html-builder-column-builder.md | 1 + html-builder-column.md | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/html-builder-column-builder.md b/html-builder-column-builder.md index 1f1fd6e..2aba799 100644 --- a/html-builder-column-builder.md +++ b/html-builder-column-builder.md @@ -31,6 +31,7 @@ $column = Column::make('id') ->searchable(true) ->orderable(true) ->render('\'
\' + (full[\'deleted_at\'] == null ? \'Active\' : \'Inactive\') + \'
\';\'\'' ) + ->render(function($row,$data){return $data == 1 ? 'Active' : 'Inactive'}) ->footer('Id') ->exportable(true) ->printable(true); diff --git a/html-builder-column.md b/html-builder-column.md index ab21bf4..f0a2b03 100644 --- a/html-builder-column.md +++ b/html-builder-column.md @@ -47,6 +47,10 @@ Orderable attribute will toggle the `ordering` ability for the defined column. D ### Render (Optional) Render attribute is a `js` script string that you can use to modify the way the column is being rendered via `javascript`. +### Export Render (Optional) +Export Render attribute is a `php callback function` that you can use to modify the way the column is being rendered via `print` or `export (CSV/Excel/PDF)`. + + ### Footer (Optional) Footer attribute will be as your `tables` column's `footer` content ``. From 4241867c5c27fa5706a17c4ecfd48ba7fa878581 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 10 May 2023 14:26:10 +0800 Subject: [PATCH 249/264] docs: controller to dataTable class --- buttons-extended.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/buttons-extended.md b/buttons-extended.md index 2811a86..3753c44 100644 --- a/buttons-extended.md +++ b/buttons-extended.md @@ -4,8 +4,8 @@ We can now extend and reuse our DataTable class inside our controller by using ` > IMPORTANT: Extended DataTable is only applicable on `^1.1` and above. - ## Upgrading from v1.0 to v1.1 + - Upgrade to `laravel-datatables-buttons:^1.1` - Rename `ajax()` method to `dataTable()` - Remove `->toJson()` from the method chain. @@ -33,6 +33,7 @@ TO ``` ## Quick Example: + ```php Route::get('datatable', function(RolesDataTable $dataTable){ return $dataTable->before(function (\Yajra\DataTables\DataTableAbstract $dataTable) { @@ -54,3 +55,19 @@ Route::get('datatable', function(RolesDataTable $dataTable){ ->render('path.to.view'); }); ``` + +## Passing data to DataTable class + +You can pass data from Controller to DataTable class using `with` api. + +```php +Route::get('datatable', function(RolesDataTable $dataTable){ + return $dataTable + ->with('key', 'value') + ->with([ + 'key2' => 'value2', + 'key3' => 'value3', + ]) + ->render('path.to.view'); +}); +``` From 183760b2eba76e07576ca8b7679314ab439dd22d Mon Sep 17 00:00:00 2001 From: Meshack Junior Date: Sat, 24 Jun 2023 21:02:48 +0300 Subject: [PATCH 250/264] Update releases.md --- releases.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/releases.md b/releases.md index f12c3a7..e09cc8a 100644 --- a/releases.md +++ b/releases.md @@ -1,18 +1,18 @@ # Release Notes -- [Laravel DataTables 7.0](#7.0) +- [Laravel DataTables 10.0](#10.0) - -## Laravel DataTables 7.0 + +## Laravel DataTables 10.0 -Laravel DataTables 7.0 splits Laravel DataTables 6.x into a main package and plugins packages for more flexibile and pluggable design. +Laravel DataTables 10.0 splits Laravel DataTables 6.x into a main package and plugins packages for more flexibile and pluggable design. ### Buttons Plugin -On Laravel DataTables 7.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. +On Laravel DataTables 10.0, service classes and files are extracted into a separate package to reduce its complexity and dependencies on other packages by default. This idea comes up from [Issue #832](https://github.com/yajra/{{package}}/issues/832) which actually makes sense since not all users are using the export functionality. ### DomPDF -`DomPDF` dependency is now optional on Laravel DataTables 7.0 and was transferred to Buttons plugin. +`DomPDF` dependency is now optional on Laravel DataTables 10.0 and was transferred to Buttons plugin. And the `Buttons` plugin will now give you a choice to install it or not. This was as a `suggest` since we now have an option to use [`snappy`](https://github.com/barryvdh/laravel-snappy) as our pdf generator. From b3b0dbf1e8d79f5366fc1e96e6d383cc0116da8a Mon Sep 17 00:00:00 2001 From: Mathieu FERRE Date: Fri, 30 Jun 2023 16:50:49 +0200 Subject: [PATCH 251/264] Update edit-column.md --- edit-column.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/edit-column.md b/edit-column.md index d778e78..2cf9542 100644 --- a/edit-column.md +++ b/edit-column.md @@ -55,3 +55,28 @@ Then create your view on `resources/views/users/datatables/name.blade.php`. ```php Hi {{ $name }}! ``` + + + +## Edit only the requested Columns + +> {tip} You can skip editing the columns that are not in your requested payload by using `editOnlySelectedColumns` before using `editColumn` + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + return DataTables::eloquent($model) + ->editColumn('id', function () { + return view('users.datatables.id'); // View will always be rendered + }) + ->editOnlySelectedColumns() + ->editColumn('name', function () { + return 'Hi ' . $user->name . '!'; // View will only be rendered if the column is in the payload + only if in the payload + }) + ->toJson(); +}); +``` From 39cd19626d28a5998fd50b127aa9e4b5469c1d48 Mon Sep 17 00:00:00 2001 From: Mohammad Reza Golestan Date: Mon, 31 Jul 2023 15:00:57 +0330 Subject: [PATCH 252/264] add exportRender --- html-builder-column-builder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-builder-column-builder.md b/html-builder-column-builder.md index 2aba799..ddaff77 100644 --- a/html-builder-column-builder.md +++ b/html-builder-column-builder.md @@ -31,7 +31,7 @@ $column = Column::make('id') ->searchable(true) ->orderable(true) ->render('\'
\' + (full[\'deleted_at\'] == null ? \'Active\' : \'Inactive\') + \'
\';\'\'' ) - ->render(function($row,$data){return $data == 1 ? 'Active' : 'Inactive'}) + ->exportRender(function($row,$data){return $data == 1 ? 'Active' : 'Inactive'}) ->footer('Id') ->exportable(true) ->printable(true); From d975b4b520ab1bb54e00f070f3f141dea44d0f4b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Wed, 13 Sep 2023 09:28:57 +0800 Subject: [PATCH 253/264] fix: cs --- search-panes-starter.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/search-panes-starter.md b/search-panes-starter.md index c363b22..25499f1 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -106,10 +106,7 @@ public function dataTable($query) : Yajra\DataTables\DataTableAbstract * values are always given in an array even if just one is selected */ function (\Illuminate\Database\Eloquent\Builder $query, array $values) { - return $query - ->whereIn( - 'id', - $values); + return $query->whereIn('id', $values); } ); } From 3c51868fffe5f8d2de7478b917bcb75fcef4bcc6 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Thu, 21 Sep 2023 11:39:29 +0800 Subject: [PATCH 254/264] bump to v10 --- html-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-installation.md b/html-installation.md index 507ce61..f616b7e 100644 --- a/html-installation.md +++ b/html-installation.md @@ -6,7 +6,7 @@ Github: https://github.com/yajra/laravel-datatables-html Run the following command in your project to get the latest version of the plugin: -`composer require yajra/laravel-datatables-html:^9.0` +`composer require yajra/laravel-datatables-html:^10.0` ## Configuration From c00d775ec30aa937e345419f6658fb22cfb628a8 Mon Sep 17 00:00:00 2001 From: Ozan Kurt Date: Fri, 29 Sep 2023 09:42:49 +0200 Subject: [PATCH 255/264] Update edit-column.md --- edit-column.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/edit-column.md b/edit-column.md index 2cf9542..022cfb7 100644 --- a/edit-column.md +++ b/edit-column.md @@ -46,16 +46,48 @@ Route::get('user-data', function() { $model = App\User::query(); return DataTables::eloquent($model) - ->editColumn('name', 'users.datatables.into') + ->editColumn('name', 'users.datatables.name') ->toJson(); + }); ``` Then create your view on `resources/views/users/datatables/name.blade.php`. + ```php Hi {{ $name }}! ``` + +## Edit Column with View and Data + +> {tip} You can use view to render your added column by passing the view path as the second argument on `editColumn` api. + +```php +use DataTables; + +Route::get('user-data', function() { + $model = App\User::query(); + + $externalData = 'External'; + + return DataTables::eloquent($model) + ->editColumn('name', ['users.datatables.name', [ + 'externalData' => $externalData, + ]]) + ->toJson(); + +}); +``` + +Then create your view on `resources/views/users/datatables/name.blade.php`. + +```php +Hi {{ $name }}! + +Here is some external data: {{ $externalData }}. +``` + ## Edit only the requested Columns From d6bf8e202dc9cee65ae4c0cac760c55aa3f930e8 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 29 Sep 2023 23:18:55 -0700 Subject: [PATCH 256/264] fix: searchPanes column def --- search-panes-starter.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/search-panes-starter.md b/search-panes-starter.md index 25499f1..2ad85a9 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -25,11 +25,27 @@ public function html() : \Yajra\DataTables\Html\Builder // Setting the dom string directly return $this->builder() ->searchPanes(SearchPane::make()) + ->addColumnDef([ + 'targets' => '_all', + 'searchPanes' => [ + 'show' => true, + 'vieTotal' => false, + 'viewCount' => false, + ], + ]) ->dom('PBfrtip'); // Alternatively set the dom with parameters return $this->builder() ->searchPanes(SearchPane::make()) + ->addColumnDef([ + 'targets' => '_all', + 'searchPanes' => [ + 'show' => true, + 'vieTotal' => false, + 'viewCount' => false, + ], + ]) ->parameters([ 'dom' => 'PBfrtip' ]); @@ -47,6 +63,14 @@ public function html() : \Yajra\DataTables\Html\Builder // Adding via class return $this->builder() ->searchPanes(SearchPane::make()) + ->addColumnDef([ + 'targets' => '_all', + 'searchPanes' => [ + 'show' => true, + 'vieTotal' => false, + 'viewCount' => false, + ], + ]) ->buttons([ \Yajra\DataTables\Html\Button::make('searchPanes') // other buttons... @@ -55,6 +79,14 @@ public function html() : \Yajra\DataTables\Html\Builder // Alternatively set the buttons with options return $this->builder() ->searchPanes(SearchPane::make()) + ->addColumnDef([ + 'targets' => '_all', + 'searchPanes' => [ + 'show' => true, + 'vieTotal' => false, + 'viewCount' => false, + ], + ]) ->parameters([ 'buttons' => ['searchPanes', /*other buttons...*/] ]); From 2f70c3cf4b56186386c918498e311b6d7a6bbbfb Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Fri, 29 Sep 2023 23:21:08 -0700 Subject: [PATCH 257/264] docs: add docs to display specific column index --- search-panes-starter.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/search-panes-starter.md b/search-panes-starter.md index 2ad85a9..7204f16 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -34,6 +34,19 @@ public function html() : \Yajra\DataTables\Html\Builder ], ]) ->dom('PBfrtip'); + + // Displaying specific column indexes + return $this->builder() + ->searchPanes(SearchPane::make()->columns([1, 2])) + ->addColumnDef([ + 'targets' => '_all', + 'searchPanes' => [ + 'show' => true, + 'vieTotal' => false, + 'viewCount' => false, + ], + ]) + ->dom('PBfrtip'); // Alternatively set the dom with parameters return $this->builder() From e4f8c8849a9f6053b8adbebd25e8719b1b47977e Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Mon, 2 Oct 2023 03:46:27 -0700 Subject: [PATCH 258/264] docs: columnDef must used when using buttons --- search-panes-starter.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/search-panes-starter.md b/search-panes-starter.md index 7204f16..394aa88 100644 --- a/search-panes-starter.md +++ b/search-panes-starter.md @@ -75,7 +75,6 @@ public function html() : \Yajra\DataTables\Html\Builder { // Adding via class return $this->builder() - ->searchPanes(SearchPane::make()) ->addColumnDef([ 'targets' => '_all', 'searchPanes' => [ @@ -91,7 +90,6 @@ public function html() : \Yajra\DataTables\Html\Builder // Alternatively set the buttons with options return $this->builder() - ->searchPanes(SearchPane::make()) ->addColumnDef([ 'targets' => '_all', 'searchPanes' => [ From e05fbe2ec418c71823087286ad1ed654b27b32b5 Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Mon, 2 Oct 2023 03:47:31 -0700 Subject: [PATCH 259/264] docs: add collapse option --- search-panes-options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/search-panes-options.md b/search-panes-options.md index 4026db4..438be85 100644 --- a/search-panes-options.md +++ b/search-panes-options.md @@ -18,6 +18,7 @@ public function html() : \Yajra\DataTables\Html\Builder // SearchPane::make()... ] ) + ->collapse(false) ->dtOpts( // Sets the options for the datatables inside the searchpanes [ 'paging' => true, From b6cc3f247617afe931cb09499bfb37a7fd42039c Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Mon, 2 Oct 2023 03:50:55 -0700 Subject: [PATCH 260/264] docs: initCollapsed option ref: https://github.com/yajra/laravel-datatables-html/pull/207 --- search-panes-options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/search-panes-options.md b/search-panes-options.md index 438be85..206a41b 100644 --- a/search-panes-options.md +++ b/search-panes-options.md @@ -18,6 +18,7 @@ public function html() : \Yajra\DataTables\Html\Builder // SearchPane::make()... ] ) + ->initCollapsed(true) ->collapse(false) ->dtOpts( // Sets the options for the datatables inside the searchpanes [ From 3f3825e60588593f72c83cd4697e5a39f6e21737 Mon Sep 17 00:00:00 2001 From: jaydons <44308248+jaydons@users.noreply.github.com> Date: Mon, 2 Oct 2023 03:54:35 -0700 Subject: [PATCH 261/264] docs: show option --- search-panes-options.md | 1 + 1 file changed, 1 insertion(+) diff --git a/search-panes-options.md b/search-panes-options.md index 206a41b..c65cd5b 100644 --- a/search-panes-options.md +++ b/search-panes-options.md @@ -18,6 +18,7 @@ public function html() : \Yajra\DataTables\Html\Builder // SearchPane::make()... ] ) + ->show(false) ->initCollapsed(true) ->collapse(false) ->dtOpts( // Sets the options for the datatables inside the searchpanes From 78ae1c86e149f4f370e82967f43656dc568fdd5c Mon Sep 17 00:00:00 2001 From: Furkan Akkoc Date: Tue, 7 Nov 2023 20:18:15 +0100 Subject: [PATCH 262/264] Add scout search --- documentation.md | 1 + scout-search.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 scout-search.md diff --git a/documentation.md b/documentation.md index 14788f5..82ea2b4 100644 --- a/documentation.md +++ b/documentation.md @@ -53,6 +53,7 @@ - [Smart Search](/docs/{{package}}/{{version}}/smart-search) - [Starts With Search](/docs/{{package}}/{{version}}/starts-with-search) - [Relationships](/docs/{{package}}/{{version}}/relationships) + - [Scout Search](/docs/{{package}}/{{version}}/scout-search) - ## Sorting/Ordering - [Manual Order](/docs/{{package}}/{{version}}/manual-order) diff --git a/scout-search.md b/scout-search.md new file mode 100644 index 0000000..5df30bb --- /dev/null +++ b/scout-search.md @@ -0,0 +1,56 @@ +# Scout Search + +**Note:** This documentation is applicable from version 10.11.0 and upwards, where external search engines can be integrated with Laravel Scout, replacing the built-in search functionality. + +Scout Search provides a fallback mechanism, so the built-in search will be used if any issues occur with the external search engines (e.g., server problems or indexing problems). + +Supported drivers: Meilisearch, Algolia + + + +## Setup + +To start using Scout Search, you need to install and configure Laravel Scout with your preferred driver. + +Once Laravel Scout is set up, you can enable Scout Search in your `dataTable` function like this: + +```php +return (new EloquentDataTable($query)) + // Enable scout search for eloquent model + ->enableScoutSearch(Product::class) + + // Add filters to scout search + ->scoutFilter(function (string $keyword) { + return 'region IN ["Germany", "France"]'; // Meilisearch + // or + return 'region:Germany OR region:France'; // Algolia + }) + + // Add filters to default search + ->filter(function (QueryBuilder $query, bool $scout_searched) { + if (!$scout_searched) + { + // Filter already added for scout search + $query->whereIn('region', ['Germany', 'France']); + } + + // Stock is not indexed so it has to be filtered after the initial scout search + $query->where('stock', '>', 50); + }, true); +``` + + + +## Additional JS script + +To control the visibility of sort icons on the frontend table, you'll need an additional JavaScript script. This script hides the sort icons when Scout Search is successful (indicating fixed ordering by search relevance) and shows them again when the search keyword is removed. + +If you are using the `laravel-datatables-html` package, you can easily include the script in your `html` function: + +```php +return $this->builder() + ->setTableId('products-table') + ->addScript('datatables::scout'); +``` + +Alternatively, you can manually fetch and include the JavaScript script into your own code from this file: resources/views/scout.blade.php From fd97eaa9092d07197b79f80497ee0a0ddb02c109 Mon Sep 17 00:00:00 2001 From: Furkan Akkoc Date: Tue, 7 Nov 2023 20:28:54 +0100 Subject: [PATCH 263/264] Add html additional js scripts --- documentation.md | 1 + html-builder-additional-scripts.md | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 html-builder-additional-scripts.md diff --git a/documentation.md b/documentation.md index 82ea2b4..5397f22 100644 --- a/documentation.md +++ b/documentation.md @@ -93,6 +93,7 @@ - [Add Action](/docs/{{package}}/{{version}}/html-builder-action) - [Add Checkbox](/docs/{{package}}/{{version}}/html-builder-checkbox) - [Add Index](/docs/{{package}}/{{version}}/html-builder-index) + - [Additional Scripts](/docs/{{package}}/{{version}}/html-builder-additional-scripts) - [Github](https://github.com/yajra/laravel-datatables-html) - ## Buttons diff --git a/html-builder-additional-scripts.md b/html-builder-additional-scripts.md new file mode 100644 index 0000000..c8a4dc1 --- /dev/null +++ b/html-builder-additional-scripts.md @@ -0,0 +1,24 @@ +# Additional JavaScript Scripts + +## General Usage + +Starting with v10.10.0, you can easily add additional JavaScript scripts as blade views in your `html` function like this: + +```php +return $this->builder() + ->addScript('your.view.name'); +``` + +## Built-in Additional Scripts + +### Scout Search + +**View:** `datatables::scout` + +Control visibility of sort icons on the frontend table. Hide sort icons when Scout Search is successful (indicating fixed ordering by search relevance) and show them again when the search keyword is removed. + +### Batch Remove Optimization + +**View:** `datatables::functions.batch_remove` + +Delete all unnecessary information before sending `remove` requests (Editor), keeping only the `DT_RowId`. Otherwise, batch remove requests may fail because of server limits. From 1ae225603eed270821005d3ccdd58113cc5e402c Mon Sep 17 00:00:00 2001 From: Alpha Olomi Date: Wed, 6 Mar 2024 14:22:02 +0300 Subject: [PATCH 264/264] Add Article Community link --- community-links.md | 1 + 1 file changed, 1 insertion(+) diff --git a/community-links.md b/community-links.md index 601f8b5..2f28828 100644 --- a/community-links.md +++ b/community-links.md @@ -6,6 +6,7 @@ You may use the links below to further understand the Laravel Datatables. ## Articles - [Laravel Datatables Tutorial With Example](https://appdividend.com/2018/04/16/laravel-datatables-tutorial-with-example/) - [How to implement DataTables server-side in laravel](https://medium.com/justlaravel/how-to-implement-datatables-server-side-in-laravel-bcacf8472d70) +- [How to get started with DataTables in Laravel](https://dev.to/alphaolomi/how-to-get-started-with-datatables-in-laravel-9-5c39) ## Videos