/home/techb158/dev.balacoffee.com/vendor/maatwebsite/excel/src/Jobs
Edit: /home/techb158/dev.balacoffee.com/vendor/maatwebsite/excel/src/Jobs/AppendPaginatedToSheet.php (3022B)
sheetExport = $sheetExport;
$this->temporaryFile = $temporaryFile;
$this->writerType = $writerType;
$this->sheetIndex = $sheetIndex;
$this->page = $page;
$this->perPage = $perPage;
}
/**
* Get the middleware the job should be dispatched through.
*
* @return array
*/
public function middleware()
{
return (method_exists($this->sheetExport, 'middleware')) ? $this->sheetExport->middleware() : [];
}
/**
* @param Writer $writer
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function handle(Writer $writer)
{
(new LocalizeJob($this->sheetExport))->handle($this, function () use ($writer) {
$writer = $writer->reopen($this->temporaryFile, $this->writerType);
$sheet = $writer->getSheetByIndex($this->sheetIndex);
$sheet->appendRows($this->chunk($this->sheetExport->query()), $this->sheetExport);
$writer->write($this->sheetExport, $this->temporaryFile, $this->writerType);
});
}
/**
* @param Builder|Relation|EloquentBuilder|ScoutBuilder $query
*/
protected function chunk($query)
{
if ($query instanceof \Laravel\Scout\Builder) {
return $query->paginate($this->perPage, 'page', $this->page)->items();
}
// Fallback
return $query->forPage($this->page, $this->perPage)->get();
}
}