From a56c70779fb25a31c47234b8c79e75570c002a72 Mon Sep 17 00:00:00 2001 From: Ion Caliman Date: Wed, 21 Jun 2023 18:59:35 +0300 Subject: [PATCH] Fix: Sync when ID's are duplicated --- src/Listeners/UpdateSyncedResource.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Listeners/UpdateSyncedResource.php b/src/Listeners/UpdateSyncedResource.php index 40d4d644..53c497a4 100644 --- a/src/Listeners/UpdateSyncedResource.php +++ b/src/Listeners/UpdateSyncedResource.php @@ -60,7 +60,10 @@ class UpdateSyncedResource extends QueueableListener } else { // If the resource doesn't exist at all in the central DB,we create // the record with all attributes, not just the synced ones. - $centralModel = $event->model->getCentralModelName()::create($event->model->getAttributes()); + $attributes = $event->model->getAttributes(); + unset($attributes['id']); + + $centralModel = $event->model->getCentralModelName()::create($attributes); event(new SyncedResourceChangedInForeignDatabase($event->model, null)); } });