Skip to content

Commit ce26b6b

Browse files
authored
Merge pull request #185 from yajra/laravel11
feat: Laravel 11 support
2 parents dc93c0e + 889d983 commit ce26b6b

17 files changed

+197
-302
lines changed

.github/workflows/continuous-integration.yml

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

2020
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}

.github/workflows/pint.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PHP Linting
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
phplint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: "laravel-pint"
13+
uses: aglipanci/[email protected]
14+
with:
15+
preset: laravel
16+
verboseMode: true
17+
- uses: stefanzweifel/git-auto-commit-action@v5
18+
with:
19+
commit_message: "fix: pint"
20+

.github/workflows/static-analysis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727

2828
strategy:
2929
matrix:
30-
php-version:
31-
- "8.1"
30+
php: [8.2, 8.3]
3231

3332
steps:
3433
- name: "Checkout code"

UPGADE.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# UPGRADE GUIDE
2+
3+
## Upgrade from 10.x to 11.x
4+
5+
1. Update the composer.json file and change the version of the package to `^11.0`:
6+
7+
```json
8+
"require": {
9+
"yajra/laravel-datatables-buttons": "^11.0"
10+
}
11+
```
12+
13+
2. Run `composer update` to update the package.
14+
15+
3. If you are using a custom class of laravel-excel to export the data, you need to update the collection method and include the return type `Collection|LazyCollection` in the method signature.
16+
17+
```php
18+
public function collection(): Collection|LazyCollection
19+
{
20+
return $this->collection;
21+
}
22+
```

composer.json

+75-62
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,78 @@
11
{
2-
"name": "yajra/laravel-datatables-buttons",
3-
"description": "Laravel DataTables Buttons Plugin.",
4-
"keywords": [
5-
"laravel",
6-
"datatables",
7-
"buttons",
8-
"jquery"
9-
],
10-
"license": "MIT",
11-
"authors": [
12-
{
13-
"name": "Arjay Angeles",
14-
"email": "[email protected]"
15-
}
16-
],
17-
"require": {
18-
"php": "^8.1",
19-
"yajra/laravel-datatables-oracle": "^10",
20-
"yajra/laravel-datatables-html": "^10",
21-
"illuminate/console": "^10"
22-
},
23-
"require-dev": {
24-
"maatwebsite/excel": "^3.1.46",
25-
"larastan/larastan": "^2.4",
26-
"orchestra/testbench": "^8",
27-
"rap2hpoutre/fast-excel": "^5.1",
28-
"barryvdh/laravel-snappy": "^1.0.1"
29-
},
30-
"autoload": {
31-
"psr-4": {
32-
"Yajra\\DataTables\\": "src/"
33-
}
34-
},
35-
"autoload-dev": {
36-
"psr-4": {
37-
"Yajra\\DataTables\\Buttons\\Tests\\": "tests/"
38-
}
39-
},
40-
"extra": {
41-
"branch-alias": {
42-
"dev-master": "10.0-dev"
2+
"name": "yajra/laravel-datatables-buttons",
3+
"description": "Laravel DataTables Buttons Plugin.",
4+
"keywords": [
5+
"laravel",
6+
"datatables",
7+
"buttons",
8+
"jquery"
9+
],
10+
"license": "MIT",
11+
"authors": [
12+
{
13+
"name": "Arjay Angeles",
14+
"email": "[email protected]"
15+
}
16+
],
17+
"require": {
18+
"php": "^8.2",
19+
"yajra/laravel-datatables-oracle": "^11",
20+
"yajra/laravel-datatables-html": "^11",
21+
"illuminate/console": "^11"
4322
},
44-
"laravel": {
45-
"providers": [
46-
"Yajra\\DataTables\\ButtonsServiceProvider"
47-
]
48-
}
49-
},
50-
"suggest": {
51-
"yajra/laravel-datatables-export": "Exporting of dataTables (excel, csv and PDF) via livewire and queue worker.",
52-
"maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.",
53-
"rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.",
54-
"dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.",
55-
"barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view."
56-
},
57-
"minimum-stability": "dev",
58-
"prefer-stable": true,
59-
"funding": [
60-
{
61-
"type": "github",
62-
"url": "https://github.com/sponsors/yajra"
63-
}
64-
]
23+
"require-dev": {
24+
"larastan/larastan": "^2.9.2",
25+
"orchestra/testbench": "^9",
26+
"laravel/pint": "^1.14",
27+
"rector/rector": "^1.0.2",
28+
"maatwebsite/excel": "^3.1.55",
29+
"rap2hpoutre/fast-excel": "^5.4"
30+
},
31+
"autoload": {
32+
"psr-4": {
33+
"Yajra\\DataTables\\": "src/"
34+
}
35+
},
36+
"autoload-dev": {
37+
"psr-4": {
38+
"Yajra\\DataTables\\Buttons\\Tests\\": "tests/"
39+
}
40+
},
41+
"extra": {
42+
"branch-alias": {
43+
"dev-master": "11.0-dev"
44+
},
45+
"laravel": {
46+
"providers": [
47+
"Yajra\\DataTables\\ButtonsServiceProvider"
48+
]
49+
}
50+
},
51+
"suggest": {
52+
"yajra/laravel-datatables-export": "Exporting of dataTables (excel, csv and PDF) via livewire and queue worker.",
53+
"maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.",
54+
"rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.",
55+
"dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.",
56+
"barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view."
57+
},
58+
"scripts": {
59+
"test": "./vendor/bin/phpunit",
60+
"pint": "./vendor/bin/pint",
61+
"rector": "./vendor/bin/rector",
62+
"stan": "./vendor/bin/phpstan analyse --memory-limit=2G --ansi --no-progress --no-interaction --configuration=phpstan.neon.dist",
63+
"pr": [
64+
"@pint",
65+
"@rector",
66+
"@stan",
67+
"@test"
68+
]
69+
},
70+
"minimum-stability": "dev",
71+
"prefer-stable": true,
72+
"funding": [
73+
{
74+
"type": "github",
75+
"url": "https://github.com/sponsors/yajra"
76+
}
77+
]
6578
}

rector.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__.'/src',
12+
__DIR__.'/tests',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
17+
18+
// define sets of rules
19+
$rectorConfig->sets([
20+
LevelSetList::UP_TO_PHP_82,
21+
]);
22+
};

src/ButtonsServiceProvider.php

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class ButtonsServiceProvider extends ServiceProvider
1212
{
1313
/**
1414
* Bootstrap the application events.
15-
*
16-
* @return void
1715
*/
1816
public function boot(): void
1917
{
@@ -54,8 +52,6 @@ protected function registerCommands(): void
5452

5553
/**
5654
* Register the service provider.
57-
*
58-
* @return void
5955
*/
6056
public function register(): void
6157
{

src/Exports/DataTablesCollectionExport.php

+4-16
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,18 @@ abstract class DataTablesCollectionExport implements FromCollection, WithHeading
1212
{
1313
use Exportable;
1414

15-
/**
16-
* @var Collection|LazyCollection
17-
*/
18-
protected $collection;
19-
20-
/**
21-
* @param Collection|LazyCollection|null $collection
22-
*/
23-
public function __construct($collection = null)
15+
protected LazyCollection|Collection $collection;
16+
17+
public function __construct(Collection|LazyCollection|null $collection = null)
2418
{
2519
$this->collection = $collection ?? new Collection;
2620
}
2721

28-
/**
29-
* @return Collection|LazyCollection
30-
*/
31-
public function collection()
22+
public function collection(): Collection|LazyCollection
3223
{
3324
return $this->collection;
3425
}
3526

36-
/**
37-
* @return array
38-
*/
3927
public function headings(): array
4028
{
4129
/** @var array $first */

src/Generators/DataTablesHtmlCommand.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand
3737
* Build the class with the given name.
3838
*
3939
* @param string $name
40-
* @return string
4140
*
4241
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
4342
*/
@@ -48,18 +47,16 @@ protected function buildClass($name): string
4847
$stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
4948

5049
$this->replaceBuilder($stub)
51-
->replaceColumns($stub)
52-
->replaceButtons($stub)
53-
->replaceDOM($stub)
54-
->replaceTableId($stub);
50+
->replaceColumns($stub)
51+
->replaceButtons($stub)
52+
->replaceDOM($stub)
53+
->replaceTableId($stub);
5554

5655
return $stub;
5756
}
5857

5958
/**
6059
* Get the stub file for the generator.
61-
*
62-
* @return string
6360
*/
6461
protected function getStub(): string
6562
{
@@ -72,7 +69,6 @@ protected function getStub(): string
7269
* Parse the name and format according to the root namespace.
7370
*
7471
* @param string $name
75-
* @return string
7672
*/
7773
protected function qualifyClass($name): string
7874
{
@@ -92,6 +88,6 @@ protected function qualifyClass($name): string
9288
$name = preg_replace('#datatablehtml$#i', 'DataTableHtml', $name);
9389
}
9490

95-
return $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name;
91+
return $this->getDefaultNamespace(trim((string) $rootNamespace, '\\')).'\\'.$name;
9692
}
9793
}

0 commit comments

Comments
 (0)