Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit 8fd6c1a

Browse files
committed
prevent remapping component id
1 parent 94f4c49 commit 8fd6c1a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/Traits/WithModelMapping.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ trait WithModelMapping
1818
public function mapModelAttributes(?Model $model = null): void
1919
{
2020
if (! is_null($model)) {
21-
collect($model->getAttributes())->each(function ($value, $property) use ($model) {
22-
if (property_exists($this, $property)) {
23-
rescue(
24-
fn () => $this->{$property} = $model->{$property},
25-
fn () => null,
26-
config('model-mapper.log') ?? false
27-
);
28-
}
29-
});
21+
collect($model->getAttributes())
22+
->except('id')
23+
->each(function ($value, $property) use ($model) {
24+
if (property_exists($this, $property)) {
25+
rescue(
26+
fn () => $this->{$property} = $model->{$property},
27+
fn () => null,
28+
config('model-mapper.log') ?? false
29+
);
30+
}
31+
});
3032
}
3133
}
3234
}

0 commit comments

Comments
 (0)