From 46342ffa7ae17bdb02b99795b5d396b371ba27d7 Mon Sep 17 00:00:00 2001 From: Josue <129712493+jnunez95@users.noreply.github.com> Date: Fri, 28 Jul 2023 09:10:24 -0500 Subject: [PATCH] Fix error export excel when instance is object (StdClass) (#10) --- src/Exportable.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Exportable.php b/src/Exportable.php index 6bc32e1..9314e9b 100644 --- a/src/Exportable.php +++ b/src/Exportable.php @@ -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(); }); }