diff --git a/src/Cloner.php b/src/Cloner.php index 5b98fbe..b054ffb 100644 --- a/src/Cloner.php +++ b/src/Cloner.php @@ -190,6 +190,11 @@ protected function duplicatePivotedRelation($relation, $relation_name, $clone) { $foreign->pivot->getCreatedAtColumn(), $foreign->pivot->getUpdatedAtColumn() ]); + + if ($foreign->pivot->incrementing) { + unset($pivot_attributes[$foreign->pivot->getKeyName()]); + } + $clone->$relation_name()->attach($foreign, $pivot_attributes); }); }