Skip to content

Commit

Permalink
Just using arrayable instead of collection mapping works
Browse files Browse the repository at this point in the history
  • Loading branch information
keithbrink committed Apr 18, 2024
1 parent 46ead2d commit ac4d692
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/Data/Base/ToArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Jasara\AmznSPA\Data\Base;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Collection;
use ReflectionClass;
use ReflectionProperty;

Expand All @@ -21,16 +20,6 @@ public function toArray(): array
$value = $value->toArray();
}

if ($value instanceof Collection) {
$value = $value->map(function (mixed $item) {
if ($item instanceof Arrayable) {
return $item->toArray();
}

return $item;
})->toArray();
}

$data[$property->getName()] = $value;
}

Expand Down

0 comments on commit ac4d692

Please sign in to comment.