generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLaravelExcel.php
43 lines (34 loc) · 1004 Bytes
/
LaravelExcel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Thomascombe\BackpackAsyncExport\Exports;
use Illuminate\Support\Facades\Log;
use Maatwebsite\Excel\Concerns\Exportable;
use Thomascombe\BackpackAsyncExport\Enums\ImportExportStatus;
use Thomascombe\BackpackAsyncExport\Models\ImportExport;
use Throwable;
abstract class LaravelExcel
{
use Exportable;
protected ImportExport $model;
public function failed(Throwable $exception): void
{
if (null !== ($model = $this->getModel())) {
$model->update([
ImportExport::COLUMN_STATUS => ImportExportStatus::Error,
ImportExport::COLUMN_ERROR => $exception->getMessage(),
]);
}
Log::error(
$exception->getMessage(),
['exception' => $exception]
);
}
public function getModel(): ?ImportExport
{
return $this->model;
}
public function setModel(ImportExport $model): self
{
$this->model = $model;
return $this;
}
}