Skip to content

Commit d2fb4bc

Browse files
committed
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)
1 parent 5e3eb43 commit d2fb4bc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/ResourceSyncing/TriggerSyncingEvents.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public static function bootTriggerSyncingEvents(): void
2828
$pivot->getCentralResourceAndTenant();
2929
});
3030

31-
static::saved(static function (self $pivot) {
31+
// Only attach when the pivot is created
32+
static::created(static function (self $pivot) {
3233
/**
3334
* @var static&Pivot $pivot
3435
* @var SyncMaster|null $centralResource

0 commit comments

Comments
 (0)