Skip to content

Commit

Permalink
Merge pull request #6 from gulaandrij/patch-1
Browse files Browse the repository at this point in the history
Update BaseModel.php
  • Loading branch information
zack6849 authored Jan 9, 2020
2 parents 3123f9d + c8e1bb0 commit 0b3e09e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function toArray()
if (is_object($value) && $value instanceof Arrayable) {
$object[$key] = $value->toArray();
}

if (is_array($value)) {
$object[$key] = array_map(static function ($item) {
return is_object($item) && $item instanceof Arrayable ? $item->toArray() : $item;
}, $value);
}
}

return $object;
Expand Down Expand Up @@ -166,4 +172,4 @@ function jsonSerialize()
{
return $this;
}
}
}

0 comments on commit 0b3e09e

Please sign in to comment.