From f3515541004b9e2d7f10a5844254fb669e4fa377 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 17 Oct 2024 13:07:16 +0200 Subject: [PATCH] Use clone operator directly to support old Laravel versions that lack a clone method --- src/Sheet.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Sheet.php b/src/Sheet.php index fe0edabf..23f0ef5c 100644 --- a/src/Sheet.php +++ b/src/Sheet.php @@ -472,7 +472,11 @@ public function fromQuery(FromQuery $sheetExport, Worksheet $worksheet) return; } - $query->clone()->chunk($this->getChunkSize($sheetExport), function ($chunk) use ($sheetExport) { + //Operate on a clone to avoid altering the original + //and use the clone operator directly to support old versions of Laravel + //that don't have a clone method in eloquent + $clonedQuery = clone $query; + $clonedQuery->chunk($this->getChunkSize($sheetExport), function ($chunk) use ($sheetExport) { $this->appendRows($chunk, $sheetExport); }); }