mirror of
https://github.com/archtechx/tenancy.git
synced 2026-08-06 10:44:04 +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:
parent
5e3eb4322c
commit
d2fb4bc0d5
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue