From 5e5baf179b99005bbc777b9d041782b009cbbabc Mon Sep 17 00:00:00 2001 From: Cathal Toomey Date: Tue, 12 May 2026 12:28:34 +0100 Subject: [PATCH] fix duplicate key error when duplicating module with files attached --- src/Repositories/Behaviors/HandleFiles.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Repositories/Behaviors/HandleFiles.php b/src/Repositories/Behaviors/HandleFiles.php index f935b40d3..0a5fe4034 100644 --- a/src/Repositories/Behaviors/HandleFiles.php +++ b/src/Repositories/Behaviors/HandleFiles.php @@ -120,7 +120,8 @@ public function afterDuplicateHandleFiles(TwillModelContract $object, TwillModel return [ $file->id => Collection::make($object->files()->getPivotColumns())->mapWithKeys( function ($attribute) use ($file) { - return [$attribute => $file->pivot->$attribute]; + $value = $attribute == 'id' ? null : $file->pivot->$attribute; + return [$attribute => $value]; } )->toArray(), ];