From 7fe9b36e4bef5fc2421d673382c6aeab40af1705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 25 Oct 2019 19:49:23 +0200 Subject: [PATCH] Tenant -> Tenants --- src/StorageDrivers/Database/DatabaseStorageDriver.php | 2 +- src/TenantManager.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/StorageDrivers/Database/DatabaseStorageDriver.php b/src/StorageDrivers/Database/DatabaseStorageDriver.php index cc28ad22..fe5e1ff5 100644 --- a/src/StorageDrivers/Database/DatabaseStorageDriver.php +++ b/src/StorageDrivers/Database/DatabaseStorageDriver.php @@ -82,7 +82,7 @@ class DatabaseStorageDriver implements StorageDriver public function findBy(string $key, $value): Tenant { // [WIP] [TODO] Temporary implementation, key has to be a custom column. - $tenant = Tenant::where($key, $value)->first(); + $tenant = Tenants::where($key, $value)->first(); if (! $tenant) { throw new TenantDoesNotExistException($value, $key); diff --git a/src/TenantManager.php b/src/TenantManager.php index 610cb7ee..ed5420ad 100644 --- a/src/TenantManager.php +++ b/src/TenantManager.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Stancl\Tenancy; +use Exception; use Illuminate\Contracts\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Application; use Illuminate\Support\Collection; @@ -224,6 +225,14 @@ class TenantManager */ public function findBy(string $key, $value): Tenant { + if ($key === null) { + throw new Exception('No key supplied.'); + } + + if ($value === null) { + throw new Exception('No value supplied.'); + } + if (! method_exists($this->storage, 'findBy')) { throw new NotImplementedException(get_class($this->storage), 'findBy', 'This method was added to storage drivers provided by the package in 2.2.0 and will be part of the StorageDriver contract in 3.0.0.'