1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-08-06 14:54:05 +00:00
tenancy/src/ResourceSyncing
lukinovec 869ad78454
Fix duplicate entry error when updating TenantPivot columns (#1469)
`TriggerSyncingEvents` registered the pivot attach listener on `saved`,
which fires on both inserts and updates. So updating pivot columns on a
`TenantPivot` (e.g. via `updateExistingPivot()`) re-ran the attach flow
and tried to create the tenant resource again, causing a duplicate entry
error.

Switched the listener to `created` so we only attach when the pivot
record is first created (detaching already uses `deleting`, so using
`created` makes things a bit more consistent).

Added a regression test before the fix
(https://github.com/archtechx/tenancy/pull/1469/commits/5e3eb4322cc487d540796317e813ac2ffe076646).
The fix
(https://github.com/archtechx/tenancy/pull/1469/commits/d2fb4bc0d524cd98ec680e973b791f475afc3548)
then made the test pass.

Also improved the `saving` listener's comment a bit so that it's clear
where the "central resource not available" exception actually comes
from, since that wasn't obvious (also added the `@throws` annotation to
`getCentralResourceAndTenant()`).

Closes #1467
2026-07-07 18:56:34 -07:00
..
Events Syncing: SyncedResourceDeleted event and DeleteResourceMapping listener 2025-11-26 05:52:48 +01:00
Listeners Syncing: Add DeleteAllTenantMappings listener 2025-11-26 05:52:55 +01:00
CentralResourceNotAvailableInPivotException.php [MINOR BC BREAK] Syncing: PivotWithRelation -> PivotWithCentralResource 2025-11-26 05:52:55 +01:00
ModelNotSyncMasterException.php reimplement broadcasting channel helpers to support model binding 2024-10-03 21:12:09 +02:00
ParsesCreationAttributes.php Resource syncing rework (#30) 2024-02-10 19:08:37 +01:00
PivotWithCentralResource.php [MINOR BC BREAK] Syncing: PivotWithRelation -> PivotWithCentralResource 2025-11-26 05:52:55 +01:00
ResourceSyncing.php [4.x] Add more relation type annotations (#1424) 2025-12-28 23:20:05 +01:00
Syncable.php Syncing: SyncedResourceDeleted event and DeleteResourceMapping listener 2025-11-26 05:52:48 +01:00
SyncMaster.php Syncing: SyncedResourceDeleted event and DeleteResourceMapping listener 2025-11-26 05:52:48 +01:00
TenantMorphPivot.php Resource syncing rework (#30) 2024-02-10 19:08:37 +01:00
TenantPivot.php Resource syncing rework (#30) 2024-02-10 19:08:37 +01:00
TriggerSyncingEvents.php Fix duplicate entry error when updating TenantPivot columns (#1469) 2026-07-07 18:56:34 -07:00