Skip to content

Commit 9a33a84

Browse files
committed
Change for correct action and method
1 parent d0774dd commit 9a33a84

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/Services/DataTable.php

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,11 @@ public function render(string $view = null, array $data = [], array $mergeData =
208208

209209
/** @var string $action */
210210
$action = $this->request()->get('action');
211+
$actionMethod = $action === 'print' ? 'printPreview' : $action;
211212

212-
if ($action == 'print') {
213-
$action = 'printPreview';
214-
}
215-
216-
if (in_array($action, $this->actions) && method_exists($this, $action)) {
213+
if (in_array($action, $this->actions) && method_exists($this, $actionMethod)) {
217214
/** @var callable $callback */
218-
$callback = [$this, $action];
215+
$callback = [$this, $actionMethod];
219216

220217
return app()->call($callback);
221218
}
@@ -230,7 +227,7 @@ public function render(string $view = null, array $data = [], array $mergeData =
230227
*/
231228
public function request(): Request
232229
{
233-
if (! $this->request) {
230+
if (!$this->request) {
234231
$this->request = app(Request::class);
235232
}
236233

@@ -355,7 +352,7 @@ public function builder(): Builder
355352
return $this->htmlBuilder = $this->htmlBuilder();
356353
}
357354

358-
if (! $this->htmlBuilder) {
355+
if (!$this->htmlBuilder) {
359356
$this->htmlBuilder = app(Builder::class);
360357
}
361358

@@ -462,7 +459,7 @@ public function excel()
462459
{
463460
set_time_limit(3600);
464461

465-
$path = $this->getFilename().'.'.strtolower($this->excelWriter);
462+
$path = $this->getFilename() . '.' . strtolower($this->excelWriter);
466463

467464
$excelFile = $this->buildExcelFile();
468465

@@ -489,11 +486,11 @@ protected function buildExcelFile()
489486
return $this->buildFastExcelFile();
490487
}
491488

492-
if (! class_exists(ExcelServiceProvider::class)) {
489+
if (!class_exists(ExcelServiceProvider::class)) {
493490
throw new Exception('Please install maatwebsite/excel to be able to use this function.');
494491
}
495492

496-
if (! new $this->exportClass instanceof DataTablesExportHandler) {
493+
if (!new $this->exportClass instanceof DataTablesExportHandler) {
497494
$collection = $this->getAjaxResponseData();
498495

499496
return new $this->exportClass($this->convertToLazyCollection($collection));
@@ -534,7 +531,7 @@ public function setFilename(string $filename): static
534531
*/
535532
protected function filename(): string
536533
{
537-
return class_basename($this).'_'.date('YmdHis');
534+
return class_basename($this) . '_' . date('YmdHis');
538535
}
539536

540537
/**
@@ -594,7 +591,7 @@ private function toColumnsCollection(array $columns): Collection
594591
public function csv()
595592
{
596593
set_time_limit(3600);
597-
$path = $this->getFilename().'.'.strtolower($this->csvWriter);
594+
$path = $this->getFilename() . '.' . strtolower($this->csvWriter);
598595

599596
$excelFile = $this->buildExcelFile();
600597

@@ -626,7 +623,7 @@ public function pdf()
626623
}
627624

628625
// @phpstan-ignore-next-line
629-
return $this->buildExcelFile()->download($this->getFilename().'.pdf', $this->pdfWriter);
626+
return $this->buildExcelFile()->download($this->getFilename() . '.pdf', $this->pdfWriter);
630627
}
631628

632629
/**
@@ -638,7 +635,7 @@ public function pdf()
638635
*/
639636
public function snappyPdf(): Response
640637
{
641-
if (! class_exists(PdfWrapper::class)) {
638+
if (!class_exists(PdfWrapper::class)) {
642639
throw new Exception('You need to install barryvdh/laravel-snappy to be able to use this feature.');
643640
}
644641

@@ -651,7 +648,7 @@ public function snappyPdf(): Response
651648

652649
$snappy->setOptions($options)->setOrientation($orientation);
653650

654-
return $snappy->loadHTML($this->printPreview())->download($this->getFilename().'.pdf');
651+
return $snappy->loadHTML($this->printPreview())->download($this->getFilename() . '.pdf');
655652
}
656653

657654
/**
@@ -741,7 +738,7 @@ protected function hasScopes(array $scopes, bool $validateAll = false): bool
741738
return in_array(get_class($scope), $scopes);
742739
});
743740

744-
return $validateAll ? count($filteredScopes) === count($scopes) : ! empty($filteredScopes);
741+
return $validateAll ? count($filteredScopes) === count($scopes) : !empty($filteredScopes);
745742
}
746743

747744
/**

0 commit comments

Comments
 (0)