Skip to content

Commit 115b42a

Browse files
committed
Use lazy to support relations
1 parent 594875e commit 115b42a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Jobs/DataTableExportJob.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Illuminate\Foundation\Bus\Dispatchable;
1515
use Illuminate\Queue\InteractsWithQueue;
1616
use Illuminate\Queue\SerializesModels;
17+
use Illuminate\Support\Arr;
1718
use Illuminate\Support\Facades\Auth;
1819
use Illuminate\Support\Str;
1920
use PhpOffice\PhpSpreadsheet\Shared\Date;
@@ -80,11 +81,11 @@ public function handle()
8081
)
8182
);
8283

83-
foreach ($dataTable->getFilteredQuery()->cursor() as $row) {
84+
foreach ($dataTable->getFilteredQuery()->lazy() as $row) {
8485
$cells = collect();
8586
$columns->map(function (Column $column, $index) use ($row, $cells) {
8687
$property = $column['data'];
87-
$value = $row->{$property} ?? '';
88+
$value = Arr::get($row, $property, '');
8889

8990
if (CellTypeHelper::isDateTimeOrDateInterval($value) || $this->wantsDateFormat($column)) {
9091
$date = $value ? Date::dateTimeToExcel(Carbon::parse($value)) : '';

0 commit comments

Comments
 (0)