diff --git a/src/Cloner.php b/src/Cloner.php index 4b3ca8b..bd117a6 100644 --- a/src/Cloner.php +++ b/src/Cloner.php @@ -185,7 +185,7 @@ protected function duplicatePivotedRelation($relation, $relation_name, $clone) { if ($this->write_connection) return; // Loop trough current relations and attach to clone - $relation->get()->each(function ($foreign) use ($clone, $relation_name) { + $relation->as('pivot')->get()->each(function ($foreign) use ($clone, $relation_name) { $pivot_attributes = Arr::except($foreign->pivot->getAttributes(), [ $foreign->pivot->getRelatedKey(), $foreign->pivot->getForeignKey(),