Skip to content

Commit 2c1a3c6

Browse files
committed
Throw exception if snappy pdf is not installed
1 parent 78b9126 commit 2c1a3c6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Services/DataTable.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Yajra\DataTables\Services;
44

5+
use Barryvdh\Snappy\PdfWrapper;
56
use Closure;
67
use Generator;
78
use Illuminate\Contracts\Support\Renderable;
@@ -621,9 +622,14 @@ public function pdf()
621622
* PDF version of the table using print preview blade template.
622623
*
623624
* @return \Illuminate\Http\Response
625+
* @throws \Yajra\DataTables\Exceptions\Exception
624626
*/
625627
public function snappyPdf(): Response
626628
{
629+
if (! class_exists(PdfWrapper::class)) {
630+
throw new Exception("You need to install barryvdh/laravel-snappy to be able to use this feature.");
631+
}
632+
627633
/** @var \Barryvdh\Snappy\PdfWrapper $snappy */
628634
$snappy = app('snappy.pdf.wrapper');
629635
$options = (array) config('datatables-buttons.snappy.options');

0 commit comments

Comments
 (0)