Skip to content

Commit f5c3325

Browse files
authored
Merge pull request #139 from nickurt/patch-1
Package `maatwebsite/excel` still being installed when you want to use `fast-excel` (or another Excel-package)
2 parents 5c8fb97 + e3a2625 commit f5c3325

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

composer.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,12 @@
1818
"php": ">=7.0",
1919
"yajra/laravel-datatables-oracle": "8.*|9.*",
2020
"yajra/laravel-datatables-html": "3.*|4.*",
21-
"maatwebsite/excel": "^3.0",
2221
"illuminate/console": "*"
2322
},
2423
"require-dev": {
2524
"mockery/mockery": "~1.0",
2625
"phpunit/phpunit": "~7.0"
2726
},
28-
"suggest": {
29-
"rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.",
30-
"barryvdh/laravel-snappy": "For exporting of dataTables to PDF."
31-
},
3227
"autoload": {
3328
"psr-4": {
3429
"Yajra\\DataTables\\": "src/"
@@ -50,6 +45,8 @@
5045
}
5146
},
5247
"suggest": {
48+
"maatwebsite/excel": "Exporting of dataTables (excel, csv and PDF) using maatwebsite package.",
49+
"rap2hpoutre/fast-excel": "Faster exporting of dataTables using fast-excel package.",
5350
"dompdf/dompdf": "Allows exporting of dataTable to PDF using the DomPDF.",
5451
"barryvdh/laravel-snappy": "Allows exporting of dataTable to PDF using the print view."
5552
},

src/ButtonsServiceProvider.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function register()
6262
$this->mergeConfigFrom(__DIR__ . '/config/config.php', 'datatables-buttons');
6363

6464
$this->app->register(HtmlServiceProvider::class);
65-
$this->app->register(ExcelServiceProvider::class);
65+
66+
if (class_exists(ExcelServiceProvider::class)) {
67+
$this->app->register(ExcelServiceProvider::class);
68+
}
6669
}
6770
}

src/Services/DataTable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ protected function buildExcelFile()
433433
return $this->buildFastExcelFile();
434434
}
435435

436+
if (! class_exists(\Maatwebsite\Excel\ExcelServiceProvider::class)) {
437+
throw new \Exception('Please install maatwebsite/excel to be able to use this function.');
438+
}
439+
436440
if (! new $this->exportClass(collect()) instanceof DataTablesExportHandler) {
437441
$collection = $this->getAjaxResponseData();
438442

0 commit comments

Comments
 (0)