Skip to content

Commit

Permalink
Respect auto-increment on pivot model
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmuscnielsen committed Sep 8, 2020
1 parent 9b4f5bf commit ab33130
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Cloner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down

0 comments on commit ab33130

Please sign in to comment.