From 2f89e223167e4be14490145c7dcc4f606d60c793 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 18 Oct 2022 13:40:23 +0800 Subject: [PATCH 1/2] chore: update stubs to the latest coding style --- src/Generators/stubs/builder.stub | 3 +-- src/Generators/stubs/datatables.stub | 9 ++++---- src/Generators/stubs/html.stub | 9 ++++---- src/config/config.php | 31 ++++++++++++++-------------- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/Generators/stubs/builder.stub b/src/Generators/stubs/builder.stub index 2ebed30..785bf13 100644 --- a/src/Generators/stubs/builder.stub +++ b/src/Generators/stubs/builder.stub @@ -18,8 +18,7 @@ class DummyClass extends DataTable */ public function dataTable(QueryBuilder $query): EloquentDataTable { - return datatables() - ->eloquent($query) + return (new EloquentDataTable($query)) ->addColumn('action', 'DummyAction') ->setRowId('id'); } diff --git a/src/Generators/stubs/datatables.stub b/src/Generators/stubs/datatables.stub index f8c5618..78c3e4f 100644 --- a/src/Generators/stubs/datatables.stub +++ b/src/Generators/stubs/datatables.stub @@ -49,11 +49,12 @@ class DummyClass extends DataTable ->setTableId('DummyTableId') ->columns($this->getColumns()) ->minifiedAjax() - ->dom('DummyDOM') + //->dom('DummyDOM') ->orderBy(1) - ->buttons( + ->selectStyleSingle() + ->buttons([ DummyButtons - ); + ]); } /** @@ -61,7 +62,7 @@ class DummyClass extends DataTable * * @return array */ - protected function getColumns(): array + public function getColumns(): array { return [ Column::computed('action') diff --git a/src/Generators/stubs/html.stub b/src/Generators/stubs/html.stub index 7bb3b91..43ffcef 100644 --- a/src/Generators/stubs/html.stub +++ b/src/Generators/stubs/html.stub @@ -21,17 +21,18 @@ class DummyClass extends DataTableHtml return $this->setTableId('DummyTableId') ->columns($this->getColumns()) ->minifiedAjax() - ->dom('DummyDOM') + //->dom('DummyDOM') ->orderBy(1) - ->buttons( + ->selectStyleSingle() + ->buttons([ DummyButtons - ); + ]); } /** * @return array */ - protected function getColumns(): array + public function getColumns(): array { return [ Column::computed('action') diff --git a/src/config/config.php b/src/config/config.php index 54bd787..51bc488 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -4,7 +4,7 @@ /* * Namespaces used by the generator. */ - 'namespace' => [ + 'namespace' => [ /* * Base namespace/directory to create the new file. * This is appended on default Laravel namespace. @@ -13,7 +13,7 @@ * With Model: App\User (default model) * Export filename: users_timestamp */ - 'base' => 'DataTables', + 'base' => 'DataTables', /* * Base namespace/directory where your model's are located. @@ -42,12 +42,12 @@ /* * Snappy PDF options. */ - 'snappy' => [ - 'options' => [ - 'no-outline' => true, - 'margin-left' => '0', - 'margin-right' => '0', - 'margin-top' => '10mm', + 'snappy' => [ + 'options' => [ + 'no-outline' => true, + 'margin-left' => '0', + 'margin-right' => '0', + 'margin-top' => '10mm', 'margin-bottom' => '10mm', ], 'orientation' => 'landscape', @@ -56,12 +56,13 @@ /* * Default html builder parameters. */ - 'parameters' => [ - 'dom' => 'Bfrtip', - 'order' => [[0, 'desc']], + 'parameters' => [ + 'dom' => 'Bfrtip', + 'order' => [[0, 'desc']], 'buttons' => [ - 'create', - 'export', + 'excel', + 'csv', + 'pdf', 'print', 'reset', 'reload', @@ -71,7 +72,7 @@ /* * Generator command default options value. */ - 'generator' => [ + 'generator' => [ /* * Default columns to generate when not set. */ @@ -80,7 +81,7 @@ /* * Default buttons to generate when not set. */ - 'buttons' => 'create,export,print,reset,reload', + 'buttons' => 'excel,csv,pdf,print,reset,reload', /* * Default DOM to generate when not set. From df85d92632995016bd92a178252119d86f4e3513 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 18 Oct 2022 13:56:28 +0800 Subject: [PATCH 2/2] chore: patch desc --- src/Generators/stubs/datatables.stub | 2 +- src/Generators/stubs/html.stub | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Generators/stubs/datatables.stub b/src/Generators/stubs/datatables.stub index 78c3e4f..c55ac4d 100644 --- a/src/Generators/stubs/datatables.stub +++ b/src/Generators/stubs/datatables.stub @@ -58,7 +58,7 @@ class DummyClass extends DataTable } /** - * Get columns. + * Get the dataTable columns definition. * * @return array */ diff --git a/src/Generators/stubs/html.stub b/src/Generators/stubs/html.stub index 43ffcef..da7f0df 100644 --- a/src/Generators/stubs/html.stub +++ b/src/Generators/stubs/html.stub @@ -30,6 +30,8 @@ class DummyClass extends DataTableHtml } /** + * Get the dataTable columns definition. + * * @return array */ public function getColumns(): array