From d2fb4bc0d524cd98ec680e973b791f475afc3548 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 7 Jul 2026 12:42:16 +0200 Subject: [PATCH] Only trigger pivot attach on creation (not on updates) Use created() instead of saved() in TriggerSyncingEvents so that updating pivot columns no longer attempts to attach. Attaching re-created the tenant resource and caused a duplicate entry error (detaching already uses deleting(), so using created() is more consistent with that anyway) --- src/ResourceSyncing/TriggerSyncingEvents.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ResourceSyncing/TriggerSyncingEvents.php b/src/ResourceSyncing/TriggerSyncingEvents.php index 059eb579..dada31db 100644 --- a/src/ResourceSyncing/TriggerSyncingEvents.php +++ b/src/ResourceSyncing/TriggerSyncingEvents.php @@ -28,7 +28,8 @@ trait TriggerSyncingEvents $pivot->getCentralResourceAndTenant(); }); - static::saved(static function (self $pivot) { + // Only attach when the pivot is created + static::created(static function (self $pivot) { /** * @var static&Pivot $pivot * @var SyncMaster|null $centralResource