Skip to content

Commit 52fe0b7

Browse files
authored
Merge pull request #15 from Weebly/eloquent-inconsistency-bugfix
Eloquent inconsistency bugfix
2 parents e54ef69 + 940c3ed commit 52fe0b7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Database/Eloquent/Relations/BelongsToMany.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\Collection;
7+
use Weebly\Mutate\Exceptions\MutateException;
78
use Illuminate\Support\Collection as BaseCollection;
89
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
910

@@ -153,7 +154,11 @@ protected function parseIds($value)
153154
if ($this->related->hasMutator($this->related->getKeyName())) {
154155
$related = $this->related;
155156
$values = array_map(function ($attribute) use ($related) {
156-
return $related->serializeAttribute($related->getKeyName(), $attribute);
157+
try {
158+
return $related->serializeAttribute($related->getKeyName(), $attribute);
159+
} catch (MutateException $e) {
160+
return $attribute;
161+
}
157162
}, $values);
158163
}
159164

0 commit comments

Comments
 (0)