1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 09:54:05 +00:00

Tenant -> Tenants

This commit is contained in:
Samuel Štancl 2019-10-25 19:49:23 +02:00
parent 2cf138a728
commit 7fe9b36e4b
2 changed files with 10 additions and 1 deletions

View file

@ -82,7 +82,7 @@ class DatabaseStorageDriver implements StorageDriver
public function findBy(string $key, $value): Tenant public function findBy(string $key, $value): Tenant
{ {
// [WIP] [TODO] Temporary implementation, key has to be a custom column. // [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) { if (! $tenant) {
throw new TenantDoesNotExistException($value, $key); throw new TenantDoesNotExistException($value, $key);

View file

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy; namespace Stancl\Tenancy;
use Exception;
use Illuminate\Contracts\Console\Kernel as ConsoleKernel; use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -224,6 +225,14 @@ class TenantManager
*/ */
public function findBy(string $key, $value): Tenant 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')) { if (! method_exists($this->storage, 'findBy')) {
throw new NotImplementedException(get_class($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.' '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.'