Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .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.0, 8.1]
php: [8.1, 8.2]
stability: [prefer-stable]

name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/coverage
composer.phar
composer.lock
/.phpunit.cache
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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/)
Expand All @@ -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)

Expand Down
21 changes: 11 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
}
],
"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",
"nunomaduro/larastan": "2.1.*",
"orchestra/testbench": "^7.3",
"rap2hpoutre/fast-excel": "^3.2",
"barryvdh/laravel-snappy": "^1.0"
"maatwebsite/excel": "^3.1.46",
"nunomaduro/larastan": "^2.4",
"orchestra/testbench": "^8",
"rap2hpoutre/fast-excel": "^5.1",
"barryvdh/laravel-snappy": "^1.0.1"
},
"autoload": {
"psr-4": {
Expand All @@ -39,7 +39,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "9.0-dev"
"dev-master": "10.0-dev"
},
"laravel": {
"providers": [
Expand All @@ -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.",
Expand Down
26 changes: 15 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<exclude>./tests/views/</exclude>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<exclude>./tests/views/</exclude>
<exclude>./tests/DataTables/</exclude>
<exclude>./tests/Providers/</exclude>
<exclude>./tests/Models/</exclude>
<exclude>./tests/TestCase.php</exclude>
</testsuite>
</testsuites>
</phpunit>
5 changes: 1 addition & 4 deletions src/Services/DataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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()
Expand Down
14 changes: 7 additions & 7 deletions tests/DataTableServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');

Expand All @@ -36,31 +36,31 @@ 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');

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

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

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

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

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

/** @test */
public function it_allows_before_response_callback()
public function it_allows_before_response_callback(): void
{
$response = $this->getAjax('users/before');
$response->assertOk();
Expand All @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion tests/DataTables/UsersDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Providers/TestServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TestServiceProvider extends ServiceProvider
{
public function boot()
public function boot(): void
{
$this->loadViewsFrom(__DIR__.'/../views', 'tests');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -62,7 +62,7 @@ protected function migrateDatabase()
}
}

protected function seedDatabase()
protected function seedDatabase(): void
{
$adminRole = Role::create(['role' => 'Administrator']);
$userRole = Role::create(['role' => 'User']);
Expand Down Expand Up @@ -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));
}
Expand Down