Skip to content

Commit

Permalink
missing value on array_map when array of models
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Oct 12, 2023
1 parent 11261ea commit a3fc50d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DataTransferObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function __serialize(): array
$value instanceof Collection => $value->first() instanceof Model ? $value->map(fn (Model $model) => $model->getAttribute($propertyBindingAttributes['using'] ?? $model->getRouteKeyName()))->join(',') : $value->join(','),
$value instanceof Arrayable => $value->toArray(),
$value instanceof \Stringable => (string) $value,
is_array($value) => head($value) instanceof Model ? implode(',', array_map(fn (Model $model) => $model->getAttribute($propertyBindingAttributes['using'] ?? $model->getRouteKeyName()))) : implode(',', $value),
is_array($value) => head($value) instanceof Model ? implode(',', array_map(fn (Model $model) => $model->getAttribute($propertyBindingAttributes['using'] ?? $model->getRouteKeyName()), $value)) : implode(',', $value),
default => $value,
};
}
Expand All @@ -224,7 +224,7 @@ public function __unserialize(array $data): void

foreach ($properties as $property) {
$key = $property->getName();

$this->{$key} = $data[$key] ?? $property->getDefaultValue();
}
}
Expand Down

0 comments on commit a3fc50d

Please sign in to comment.