1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 06:54:03 +00:00

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)
This commit is contained in:
lukinovec 2026-07-07 12:42:16 +02:00
parent 5e3eb4322c
commit d2fb4bc0d5

View file

@ -28,7 +28,8 @@ trait TriggerSyncingEvents
$pivot->getCentralResourceAndTenant(); $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 static&Pivot $pivot
* @var SyncMaster|null $centralResource * @var SyncMaster|null $centralResource