Skip to content

Commit e0b75c0

Browse files
authored
Merge pull request #169 from yajra/l10-prep
feat: Laravel 10 compatibility
2 parents 6332449 + e809601 commit e0b75c0

File tree

10 files changed

+49
-44
lines changed

10 files changed

+49
-44
lines changed

.github/workflows/continuous-integration.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [8.0, 8.1]
17+
php: [8.1, 8.2]
1818
stability: [prefer-stable]
1919

2020
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
@@ -42,4 +42,4 @@ jobs:
4242
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
4343

4444
- name: Execute tests
45-
run: vendor/bin/phpunit --verbose
45+
run: vendor/bin/phpunit

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/coverage
33
composer.phar
44
composer.lock
5+
/.phpunit.cache

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Laravel DataTables Buttons Plugin
22

3-
[![Laravel 9.x](https://img.shields.io/badge/Laravel-9.x-orange.svg)](http://laravel.com)
3+
[![Laravel 10.x](https://img.shields.io/badge/Laravel-10.x-orange.svg)](http://laravel.com)
44
[![Latest Stable Version](https://img.shields.io/packagist/v/yajra/laravel-datatables-buttons.svg)](https://packagist.org/packages/yajra/laravel-datatables-buttons)
55
[![Build Status](https://travis-ci.org/yajra/laravel-datatables-buttons.svg?branch=master)](https://travis-ci.org/yajra/laravel-datatables-buttons)
66
[![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
1111

1212
## Requirements
1313

14-
- [PHP >= 8.0.2](http://php.net/)
15-
- [Laravel 9.x](https://github.com/laravel/framework)
14+
- [PHP >= 8.1](http://php.net/)
15+
- [Laravel 10.x](https://github.com/laravel/framework)
1616
- [Laravel DataTables](https://github.com/yajra/laravel-datatables)
1717
- [jQuery DataTables v1.10.x](http://datatables.net/)
1818
- [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
2727
|:--------------|:--------|
2828
| 8.x and below | 4.x |
2929
| 9.x | 9.x |
30+
| 10.x | 10.x |
3031

3132
## Quick Installation
3233

33-
`composer require yajra/laravel-datatables-buttons:^9.0`
34+
`composer require yajra/laravel-datatables-buttons:^10`
3435

3536
#### Service Provider (Optional on Laravel 5.5)
3637

composer.json

+11-10
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^8.0.2",
19-
"yajra/laravel-datatables-oracle": "10.*",
20-
"yajra/laravel-datatables-html": "9.*",
21-
"illuminate/console": "*"
18+
"php": "^8.1",
19+
"yajra/laravel-datatables-oracle": "^10",
20+
"yajra/laravel-datatables-html": "^10",
21+
"illuminate/console": "^10"
2222
},
2323
"require-dev": {
24-
"maatwebsite/excel": "^3.1.40",
25-
"nunomaduro/larastan": "2.1.*",
26-
"orchestra/testbench": "^7.3",
27-
"rap2hpoutre/fast-excel": "^3.2",
28-
"barryvdh/laravel-snappy": "^1.0"
24+
"maatwebsite/excel": "^3.1.46",
25+
"nunomaduro/larastan": "^2.4",
26+
"orchestra/testbench": "^8",
27+
"rap2hpoutre/fast-excel": "^5.1",
28+
"barryvdh/laravel-snappy": "^1.0.1"
2929
},
3030
"autoload": {
3131
"psr-4": {
@@ -39,7 +39,7 @@
3939
},
4040
"extra": {
4141
"branch-alias": {
42-
"dev-master": "9.0-dev"
42+
"dev-master": "10.0-dev"
4343
},
4444
"laravel": {
4545
"providers": [
@@ -48,6 +48,7 @@
4848
}
4949
},
5050
"suggest": {
51+
"yajra/laravel-datatables-export": "Exporting of dataTables (excel, csv and PDF) via livewire and queue worker.",
5152
"maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.",
5253
"rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.",
5354
"dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.",

phpunit.xml.dist

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
44
bootstrap="vendor/autoload.php"
55
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
96
processIsolation="false"
107
stopOnFailure="false"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false"
1111
>
12-
<testsuites>
13-
<testsuite name="Package Test Suite">
14-
<directory suffix=".php">./tests/</directory>
15-
<exclude>./tests/views/</exclude>
16-
</testsuite>
17-
</testsuites>
12+
<testsuites>
13+
<testsuite name="Package Test Suite">
14+
<directory suffix=".php">./tests/</directory>
15+
<exclude>./tests/views/</exclude>
16+
<exclude>./tests/DataTables/</exclude>
17+
<exclude>./tests/Providers/</exclude>
18+
<exclude>./tests/Models/</exclude>
19+
<exclude>./tests/TestCase.php</exclude>
20+
</testsuite>
21+
</testsuites>
1822
</phpunit>

src/Services/DataTable.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ public function render(string $view = null, array $data = [], array $mergeData =
217217
return app()->call($callback);
218218
}
219219

220+
/** @phpstan-ignore-next-line */
220221
return view($view, $data, $mergeData)->with($this->dataTableVariable, $this->getHtmlBuilder());
221222
}
222223

@@ -610,10 +611,6 @@ public function csv()
610611
*
611612
* @return \Illuminate\Http\Response|string|\Symfony\Component\HttpFoundation\StreamedResponse
612613
*
613-
* @throws \Box\Spout\Common\Exception\IOException
614-
* @throws \Box\Spout\Common\Exception\InvalidArgumentException
615-
* @throws \Box\Spout\Common\Exception\UnsupportedTypeException
616-
* @throws \Box\Spout\Writer\Exception\WriterNotOpenedException
617614
* @throws \Exception
618615
*/
619616
public function pdf()

tests/DataTableServiceTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class DataTableServiceTest extends TestCase
1515
use DatabaseTransactions;
1616

1717
/** @test */
18-
public function it_can_handle_ajax_request()
18+
public function it_can_handle_ajax_request(): void
1919
{
2020
$response = $this->getAjax('/users');
2121

@@ -27,7 +27,7 @@ public function it_can_handle_ajax_request()
2727
}
2828

2929
/** @test */
30-
public function it_returns_view_on_normal_get_request()
30+
public function it_returns_view_on_normal_get_request(): void
3131
{
3232
$response = $this->get('users');
3333

@@ -36,31 +36,31 @@ public function it_returns_view_on_normal_get_request()
3636
}
3737

3838
/** @test */
39-
public function it_can_return_a_csv_file()
39+
public function it_can_return_a_csv_file(): void
4040
{
4141
$response = $this->get('users?action=csv');
4242

4343
$this->assertInstanceOf(BinaryFileResponse::class, $response->baseResponse);
4444
}
4545

4646
/** @test */
47-
public function it_can_return_a_xls_file()
47+
public function it_can_return_a_xls_file(): void
4848
{
4949
$response = $this->get('users?action=excel');
5050

5151
$this->assertInstanceOf(BinaryFileResponse::class, $response->baseResponse);
5252
}
5353

5454
/** @test */
55-
public function it_can_return_a_pdf_file()
55+
public function it_can_return_a_pdf_file(): void
5656
{
5757
$response = $this->get('users?action=pdf');
5858

5959
$this->assertInstanceOf(Response::class, $response->baseResponse);
6060
}
6161

6262
/** @test */
63-
public function it_allows_before_response_callback()
63+
public function it_allows_before_response_callback(): void
6464
{
6565
$response = $this->getAjax('users/before');
6666
$response->assertOk();
@@ -70,7 +70,7 @@ public function it_allows_before_response_callback()
7070
}
7171

7272
/** @test */
73-
public function it_allows_response_callback()
73+
public function it_allows_response_callback(): void
7474
{
7575
$response = $this->getAjax('users/response');
7676
$response->assertOk();

tests/DataTables/UsersDataTable.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class UsersDataTable extends DataTable
1515
*/
1616
public function dataTable(Builder $query): EloquentDataTable
1717
{
18-
return datatables()->eloquent($query)->setRowId('id');
18+
return (new EloquentDataTable($query))
19+
->setRowId('id');
1920
}
2021

2122
public function query(User $user): Builder

tests/Providers/TestServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class TestServiceProvider extends ServiceProvider
88
{
9-
public function boot()
9+
public function boot(): void
1010
{
1111
$this->loadViewsFrom(__DIR__.'/../views', 'tests');
1212
}

tests/TestCase.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected function setUp(): void
2323
$this->seedDatabase();
2424
}
2525

26-
protected function migrateDatabase()
26+
protected function migrateDatabase(): void
2727
{
2828
/** @var \Illuminate\Database\Schema\Builder $schemaBuilder */
2929
$schemaBuilder = $this->app['db']->connection()->getSchemaBuilder();
@@ -62,7 +62,7 @@ protected function migrateDatabase()
6262
}
6363
}
6464

65-
protected function seedDatabase()
65+
protected function seedDatabase(): void
6666
{
6767
$adminRole = Role::create(['role' => 'Administrator']);
6868
$userRole = Role::create(['role' => 'User']);
@@ -115,12 +115,12 @@ protected function getPackageProviders($app): array
115115
];
116116
}
117117

118-
public function getAjax($uri, array $headers = []): TestResponse
118+
public function getAjax(string $uri, array $headers = []): TestResponse
119119
{
120120
return $this->getJson($uri, array_merge(['X-Requested-With' => 'XMLHttpRequest'], $headers));
121121
}
122122

123-
public function postAjax($uri, array $headers = []): TestResponse
123+
public function postAjax(string $uri, array $headers = []): TestResponse
124124
{
125125
return $this->postJson($uri, array_merge(['X-Requested-With' => 'XMLHttpRequest'], $headers));
126126
}

0 commit comments

Comments
 (0)