diff --git a/src/Contracts/StorageDriver.php b/src/Contracts/StorageDriver.php index c0ceec82..a974fe04 100644 --- a/src/Contracts/StorageDriver.php +++ b/src/Contracts/StorageDriver.php @@ -6,9 +6,6 @@ namespace Stancl\Tenancy\Contracts; use Stancl\Tenancy\Tenant; -// todo this class now manages types (json encoding) -// make sure ids are not json encoded - interface StorageDriver { public function createTenant(Tenant $tenant): void; diff --git a/src/Exceptions/TenantStorageException.php b/src/Exceptions/TenantStorageException.php new file mode 100644 index 00000000..5e4a084d --- /dev/null +++ b/src/Exceptions/TenantStorageException.php @@ -0,0 +1,6 @@ +storage->getIdKey() === $key) throw new Exception("Can't override ID")? - // and the responsibility of not overriding domains is up to the storage driver + if ($this->storage->getIdKey() === $key) { + throw new TenantStorageException("The tenant's id can't be changed."); + } if (is_array($key)) { $this->storage->putMany($key);