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); }); }