Skip to content

Commit

Permalink
Use clone operator directly to support old Laravel versions that lack…
Browse files Browse the repository at this point in the history
… a clone method
  • Loading branch information
Synchro committed Oct 17, 2024
1 parent 3bc628f commit f351554
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down

0 comments on commit f351554

Please sign in to comment.