From 928e9b44ceecfd28ebc2fc5c2d49af5e857fd670 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 09:54:50 +0800 Subject: [PATCH 01/12] build: laravel 10 deps --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 5be84e8..292b3ed 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,10 @@ } ], "require": { - "php": "^8.0.2", - "yajra/laravel-datatables-oracle": "10.*", - "yajra/laravel-datatables-html": "9.*", - "illuminate/console": "*" + "php": "^8.1", + "yajra/laravel-datatables-oracle": "^10", + "yajra/laravel-datatables-html": "^10", + "illuminate/console": "^10" }, "require-dev": { "maatwebsite/excel": "^3.1.40", @@ -39,7 +39,7 @@ }, "extra": { "branch-alias": { - "dev-master": "9.0-dev" + "dev-master": "10.0-dev" }, "laravel": { "providers": [ From dfc482ad19553494e32d32542ba050761f4c347c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 09:56:24 +0800 Subject: [PATCH 02/12] chore: drop 8, add 8.2 --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c58ccce..49033a2 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.0, 8.1] + php: [8.1, 8.2] stability: [prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.stability }} From cf765cb1d8d86d2229272d635d2e8cdef26839cf Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 12:08:46 +0800 Subject: [PATCH 03/12] docs: laravel 10 --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 69ca495..92c7c53 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Laravel DataTables Buttons Plugin -[![Laravel 9.x](https://img.shields.io/badge/Laravel-9.x-orange.svg)](http://laravel.com) +[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-orange.svg)](http://laravel.com) [![Latest Stable Version](https://img.shields.io/packagist/v/yajra/laravel-datatables-buttons.svg)](https://packagist.org/packages/yajra/laravel-datatables-buttons) [![Build Status](https://travis-ci.org/yajra/laravel-datatables-buttons.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables-buttons) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yajra/laravel-datatables-buttons/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yajra/laravel-datatables-buttons/?branch=master) @@ -11,8 +11,8 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave ## Requirements -- [PHP >= 8.0.2](http://php.net/) -- [Laravel 9.x](https://github.com/laravel/framework) +- [PHP >= 8.1](http://php.net/) +- [Laravel 10.x](https://github.com/laravel/framework) - [Laravel DataTables](https://github.com/yajra/laravel-datatables) - [jQuery DataTables v1.10.x](http://datatables.net/) - [jQuery DataTables Buttons Extension](https://datatables.net/reference/button/) @@ -27,10 +27,11 @@ This package is a plugin of [Laravel DataTables](https://github.com/yajra/larave |:--------------|:--------| | 8.x and below | 4.x | | 9.x | 9.x | +| 10.x | 10.x | ## Quick Installation -`composer require yajra/laravel-datatables-buttons:^9.0` +`composer require yajra/laravel-datatables-buttons:^10` #### Service Provider (Optional on Laravel 5.5) From cabf1f865e9b6cf374c20588390dbce951ce7e74 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 12:38:16 +0800 Subject: [PATCH 04/12] build: testbench 8 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 292b3ed..a3a231b 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ }, "require-dev": { "maatwebsite/excel": "^3.1.40", - "nunomaduro/larastan": "2.1.*", - "orchestra/testbench": "^7.3", + "nunomaduro/larastan": "^2.4", + "orchestra/testbench": "^8", "rap2hpoutre/fast-excel": "^3.2", "barryvdh/laravel-snappy": "^1.0" }, From 1eca9273da58d48578b3f9bd1eb8faafc65332eb Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 12:54:05 +0800 Subject: [PATCH 05/12] build: suggest export package --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index a3a231b..9a8cbe6 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,7 @@ } }, "suggest": { + "yajra/laravel-datatables-export": "Exporting of dataTables (excel, csv and PDF) via livewire and queue worker.", "maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.", "rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.", "dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.", From bb603c75c7eec49adb4368a935a12d444bb732b1 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 12:57:45 +0800 Subject: [PATCH 06/12] chore: add return types --- tests/DataTableServiceTest.php | 14 +++++++------- tests/DataTables/UsersDataTable.php | 3 ++- tests/Providers/TestServiceProvider.php | 2 +- tests/TestCase.php | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/DataTableServiceTest.php b/tests/DataTableServiceTest.php index 341392a..0afcebb 100644 --- a/tests/DataTableServiceTest.php +++ b/tests/DataTableServiceTest.php @@ -15,7 +15,7 @@ class DataTableServiceTest extends TestCase use DatabaseTransactions; /** @test */ - public function it_can_handle_ajax_request() + public function it_can_handle_ajax_request(): void { $response = $this->getAjax('/users'); @@ -27,7 +27,7 @@ public function it_can_handle_ajax_request() } /** @test */ - public function it_returns_view_on_normal_get_request() + public function it_returns_view_on_normal_get_request(): void { $response = $this->get('users'); @@ -36,7 +36,7 @@ public function it_returns_view_on_normal_get_request() } /** @test */ - public function it_can_return_a_csv_file() + public function it_can_return_a_csv_file(): void { $response = $this->get('users?action=csv'); @@ -44,7 +44,7 @@ public function it_can_return_a_csv_file() } /** @test */ - public function it_can_return_a_xls_file() + public function it_can_return_a_xls_file(): void { $response = $this->get('users?action=excel'); @@ -52,7 +52,7 @@ public function it_can_return_a_xls_file() } /** @test */ - public function it_can_return_a_pdf_file() + public function it_can_return_a_pdf_file(): void { $response = $this->get('users?action=pdf'); @@ -60,7 +60,7 @@ public function it_can_return_a_pdf_file() } /** @test */ - public function it_allows_before_response_callback() + public function it_allows_before_response_callback(): void { $response = $this->getAjax('users/before'); $response->assertOk(); @@ -70,7 +70,7 @@ public function it_allows_before_response_callback() } /** @test */ - public function it_allows_response_callback() + public function it_allows_response_callback(): void { $response = $this->getAjax('users/response'); $response->assertOk(); diff --git a/tests/DataTables/UsersDataTable.php b/tests/DataTables/UsersDataTable.php index 374620c..66e8e29 100644 --- a/tests/DataTables/UsersDataTable.php +++ b/tests/DataTables/UsersDataTable.php @@ -15,7 +15,8 @@ class UsersDataTable extends DataTable */ public function dataTable(Builder $query): EloquentDataTable { - return datatables()->eloquent($query)->setRowId('id'); + return (new EloquentDataTable($query)) + ->setRowId('id'); } public function query(User $user): Builder diff --git a/tests/Providers/TestServiceProvider.php b/tests/Providers/TestServiceProvider.php index ee09792..23ca2f6 100644 --- a/tests/Providers/TestServiceProvider.php +++ b/tests/Providers/TestServiceProvider.php @@ -6,7 +6,7 @@ class TestServiceProvider extends ServiceProvider { - public function boot() + public function boot(): void { $this->loadViewsFrom(__DIR__.'/../views', 'tests'); } diff --git a/tests/TestCase.php b/tests/TestCase.php index e72296a..094d576 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -23,7 +23,7 @@ protected function setUp(): void $this->seedDatabase(); } - protected function migrateDatabase() + protected function migrateDatabase(): void { /** @var \Illuminate\Database\Schema\Builder $schemaBuilder */ $schemaBuilder = $this->app['db']->connection()->getSchemaBuilder(); @@ -62,7 +62,7 @@ protected function migrateDatabase() } } - protected function seedDatabase() + protected function seedDatabase(): void { $adminRole = Role::create(['role' => 'Administrator']); $userRole = Role::create(['role' => 'User']); @@ -115,12 +115,12 @@ protected function getPackageProviders($app): array ]; } - public function getAjax($uri, array $headers = []): TestResponse + public function getAjax(string $uri, array $headers = []): TestResponse { return $this->getJson($uri, array_merge(['X-Requested-With' => 'XMLHttpRequest'], $headers)); } - public function postAjax($uri, array $headers = []): TestResponse + public function postAjax(string $uri, array $headers = []): TestResponse { return $this->postJson($uri, array_merge(['X-Requested-With' => 'XMLHttpRequest'], $headers)); } From 2cec7d01e9652c62532ac406fef2dfff266b27d4 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 15:55:14 +0800 Subject: [PATCH 07/12] build: use fast-excel 5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9a8cbe6..a35cbba 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "maatwebsite/excel": "^3.1.40", "nunomaduro/larastan": "^2.4", "orchestra/testbench": "^8", - "rap2hpoutre/fast-excel": "^3.2", + "rap2hpoutre/fast-excel": "^5", "barryvdh/laravel-snappy": "^1.0" }, "autoload": { From cbeacda4a02f7745233585596644bae03a18151c Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 16:09:00 +0800 Subject: [PATCH 08/12] chore: migrate phpunit config --- .gitignore | 1 + phpunit.xml.dist | 23 +++++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index df0e1ea..cf5ef41 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /coverage composer.phar composer.lock +/.phpunit.cache diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b4af771..05fa988 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,9 @@ - - - - ./tests/ - ./tests/views/ - - + + + + ./tests/ + ./tests/views/ + + From 03a6d2f7c648036644bcdc8b6bc0370f14ed1cbc Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 16:21:29 +0800 Subject: [PATCH 09/12] chore: bump dev versions --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index a35cbba..7bd7cc7 100644 --- a/composer.json +++ b/composer.json @@ -21,11 +21,11 @@ "illuminate/console": "^10" }, "require-dev": { - "maatwebsite/excel": "^3.1.40", + "maatwebsite/excel": "^3.1.46", "nunomaduro/larastan": "^2.4", "orchestra/testbench": "^8", - "rap2hpoutre/fast-excel": "^5", - "barryvdh/laravel-snappy": "^1.0" + "rap2hpoutre/fast-excel": "^5.1", + "barryvdh/laravel-snappy": "^1.0.1" }, "autoload": { "psr-4": { From e626dfd7b22f76eacb23c963be8e355366e794d0 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 16:21:39 +0800 Subject: [PATCH 10/12] fix: phpstan --- src/Services/DataTable.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Services/DataTable.php b/src/Services/DataTable.php index a3419d0..b00ff8d 100644 --- a/src/Services/DataTable.php +++ b/src/Services/DataTable.php @@ -217,6 +217,7 @@ public function render(string $view = null, array $data = [], array $mergeData = return app()->call($callback); } + /** @phpstan-ignore-next-line */ return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder()); } @@ -610,10 +611,6 @@ public function csv() * * @return \Illuminate\Http\Response|string|\Symfony\Component\HttpFoundation\StreamedResponse * - * @throws \Box\Spout\Common\Exception\IOException - * @throws \Box\Spout\Common\Exception\InvalidArgumentException - * @throws \Box\Spout\Common\Exception\UnsupportedTypeException - * @throws \Box\Spout\Writer\Exception\WriterNotOpenedException * @throws \Exception */ public function pdf() From 870732f7340d6066298fd83131aef50672a85e80 Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 16:24:26 +0800 Subject: [PATCH 11/12] fix: Unknown option "--verbose" --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 49033a2..eb4a0a6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -42,4 +42,4 @@ jobs: command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress - name: Execute tests - run: vendor/bin/phpunit --verbose + run: vendor/bin/phpunit From e80960138afccad6fad804d9c4e4475087078a9b Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 7 Feb 2023 17:08:21 +0800 Subject: [PATCH 12/12] fix: phpunit warning, exclude files --- phpunit.xml.dist | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 05fa988..f258a25 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,9 +1,22 @@ - + ./tests/ ./tests/views/ + ./tests/DataTables/ + ./tests/Providers/ + ./tests/Models/ + ./tests/TestCase.php