From a908e75757878042c8d8a91c23d9584a350f1b78 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 2 Jul 2017 16:28:29 +0300 Subject: [PATCH] Fix for duplicate public ids/keys --- app/Models/EntityModel.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Models/EntityModel.php b/app/Models/EntityModel.php index 977f31823a8e..f1c73ed70e2c 100644 --- a/app/Models/EntityModel.php +++ b/app/Models/EntityModel.php @@ -396,6 +396,13 @@ class EntityModel extends Eloquent $nextId = static::getNextPublicId($this->account_id); if ($nextId != $this->public_id) { $this->public_id = $nextId; + if (env('MULTI_DB_ENABLED')) { + if ($this->contact_key) { + $this->contact_key = strtolower(str_random(RANDOM_KEY_LENGTH)); + } elseif ($this->invitation_key) { + $this->invitation_key = strtolower(str_random(RANDOM_KEY_LENGTH)); + } + } return $this->save($options); } }