Skip to content

Commit

Permalink
Fix error export excel when instance is object (StdClass) (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnunez95 authored Jul 28, 2023
1 parent d7aa041 commit 46342ff
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Exportable.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ private function writeRowsFromCollection($writer, Collection $collection, ?calla
// createRowFromArray works only with arrays
if (!is_array($collection->first())) {
$collection = $collection->map(function ($value) {
if (is_object($value) && !($value instanceof Collection)) {
return (array) $value;
}

return $value->toArray();
});
}
Expand Down

0 comments on commit 46342ff

Please sign in to comment.