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

WIP findBy()

This commit is contained in:
Samuel Štancl 2019-10-24 18:57:30 +02:00
parent 0e39bec265
commit 696863b1d4
3 changed files with 37 additions and 4 deletions

View file

@ -8,6 +8,7 @@ use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Stancl\Tenancy\Contracts\TenantCannotBeCreatedException;
use Stancl\Tenancy\Exceptions\NotImplementedException;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException;
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseMigrator;
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseSeeder;
@ -200,6 +201,26 @@ class TenantManager
return $this->storage->findByDomain($domain);
}
/**
* Find a tenant using an arbitrary key.
*
* @param string $key
* @param mixed $value
* @return Tenant
* @throws TenantCouldNotBeIdentifiedException
* @throws NotImplementedException
*/
public function findBy(string $key, $value): Tenant
{
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."
);
}
return $this->storage->find($key, $value);
}
/**
* Get all tenants.
*