Skip to content

Commit

Permalink
Merge pull request #185 from yajra/laravel11
Browse files Browse the repository at this point in the history
feat: Laravel 11 support
  • Loading branch information
yajra authored Mar 14, 2024
2 parents dc93c0e + 889d983 commit ce26b6b
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.1, 8.2]
php: [8.2, 8.3]
stability: [prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PHP Linting
on:
pull_request:
push:
branches:
- master
jobs:
phplint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "laravel-pint"
uses: aglipanci/[email protected]
with:
preset: laravel
verboseMode: true
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "fix: pint"

3 changes: 1 addition & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:

strategy:
matrix:
php-version:
- "8.1"
php: [8.2, 8.3]

steps:
- name: "Checkout code"
Expand Down
22 changes: 22 additions & 0 deletions UPGADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# UPGRADE GUIDE

## Upgrade from 10.x to 11.x

1. Update the composer.json file and change the version of the package to `^11.0`:

```json
"require": {
"yajra/laravel-datatables-buttons": "^11.0"
}
```

2. Run `composer update` to update the package.

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.

```php
public function collection(): Collection|LazyCollection
{
return $this->collection;
}
```
137 changes: 75 additions & 62 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,65 +1,78 @@
{
"name": "yajra/laravel-datatables-buttons",
"description": "Laravel DataTables Buttons Plugin.",
"keywords": [
"laravel",
"datatables",
"buttons",
"jquery"
],
"license": "MIT",
"authors": [
{
"name": "Arjay Angeles",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1",
"yajra/laravel-datatables-oracle": "^10",
"yajra/laravel-datatables-html": "^10",
"illuminate/console": "^10"
},
"require-dev": {
"maatwebsite/excel": "^3.1.46",
"larastan/larastan": "^2.4",
"orchestra/testbench": "^8",
"rap2hpoutre/fast-excel": "^5.1",
"barryvdh/laravel-snappy": "^1.0.1"
},
"autoload": {
"psr-4": {
"Yajra\\DataTables\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yajra\\DataTables\\Buttons\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "10.0-dev"
"name": "yajra/laravel-datatables-buttons",
"description": "Laravel DataTables Buttons Plugin.",
"keywords": [
"laravel",
"datatables",
"buttons",
"jquery"
],
"license": "MIT",
"authors": [
{
"name": "Arjay Angeles",
"email": "[email protected]"
}
],
"require": {
"php": "^8.2",
"yajra/laravel-datatables-oracle": "^11",
"yajra/laravel-datatables-html": "^11",
"illuminate/console": "^11"
},
"laravel": {
"providers": [
"Yajra\\DataTables\\ButtonsServiceProvider"
]
}
},
"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.",
"barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view."
},
"minimum-stability": "dev",
"prefer-stable": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/yajra"
}
]
"require-dev": {
"larastan/larastan": "^2.9.2",
"orchestra/testbench": "^9",
"laravel/pint": "^1.14",
"rector/rector": "^1.0.2",
"maatwebsite/excel": "^3.1.55",
"rap2hpoutre/fast-excel": "^5.4"
},
"autoload": {
"psr-4": {
"Yajra\\DataTables\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Yajra\\DataTables\\Buttons\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "11.0-dev"
},
"laravel": {
"providers": [
"Yajra\\DataTables\\ButtonsServiceProvider"
]
}
},
"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.",
"barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view."
},
"scripts": {
"test": "./vendor/bin/phpunit",
"pint": "./vendor/bin/pint",
"rector": "./vendor/bin/rector",
"stan": "./vendor/bin/phpstan analyse --memory-limit=2G --ansi --no-progress --no-interaction --configuration=phpstan.neon.dist",
"pr": [
"@pint",
"@rector",
"@stan",
"@test"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/yajra"
}
]
}
22 changes: 22 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__.'/src',
__DIR__.'/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,
]);
};
4 changes: 0 additions & 4 deletions src/ButtonsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class ButtonsServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot(): void
{
Expand Down Expand Up @@ -54,8 +52,6 @@ protected function registerCommands(): void

/**
* Register the service provider.
*
* @return void
*/
public function register(): void
{
Expand Down
20 changes: 4 additions & 16 deletions src/Exports/DataTablesCollectionExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,18 @@ abstract class DataTablesCollectionExport implements FromCollection, WithHeading
{
use Exportable;

/**
* @var Collection|LazyCollection
*/
protected $collection;

/**
* @param Collection|LazyCollection|null $collection
*/
public function __construct($collection = null)
protected LazyCollection|Collection $collection;

public function __construct(Collection|LazyCollection|null $collection = null)
{
$this->collection = $collection ?? new Collection;
}

/**
* @return Collection|LazyCollection
*/
public function collection()
public function collection(): Collection|LazyCollection
{
return $this->collection;
}

/**
* @return array
*/
public function headings(): array
{
/** @var array $first */
Expand Down
14 changes: 5 additions & 9 deletions src/Generators/DataTablesHtmlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand
* Build the class with the given name.
*
* @param string $name
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
Expand All @@ -48,18 +47,16 @@ protected function buildClass($name): string
$stub = $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);

$this->replaceBuilder($stub)
->replaceColumns($stub)
->replaceButtons($stub)
->replaceDOM($stub)
->replaceTableId($stub);
->replaceColumns($stub)
->replaceButtons($stub)
->replaceDOM($stub)
->replaceTableId($stub);

return $stub;
}

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub(): string
{
Expand All @@ -72,7 +69,6 @@ protected function getStub(): string
* Parse the name and format according to the root namespace.
*
* @param string $name
* @return string
*/
protected function qualifyClass($name): string
{
Expand All @@ -92,6 +88,6 @@ protected function qualifyClass($name): string
$name = preg_replace('#datatablehtml$#i', 'DataTableHtml', $name);
}

return $this->getDefaultNamespace(trim($rootNamespace, "\\"))."\\".$name;
return $this->getDefaultNamespace(trim((string) $rootNamespace, "\\"))."\\".$name;
}
}
Loading

0 comments on commit ce26b6b

Please sign in to comment.