mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 12:44:02 +00:00
WIP findBy()
This commit is contained in:
parent
0e39bec265
commit
696863b1d4
3 changed files with 37 additions and 4 deletions
|
|
@ -1,15 +1,14 @@
|
|||
# Contributing
|
||||
|
||||
## Code style
|
||||
|
||||
StyleCI will automatically fix code style violations in your pull requests.
|
||||
StyleCI will flag code style violations in your pull requests.
|
||||
|
||||
## Running tests
|
||||
|
||||
### With Docker
|
||||
If you have Docker installed, simply run ./test. When you're done testing, run docker-compose down to shut down the containers.
|
||||
If you have Docker installed, simply run ./fulltest. When you're done testing, run docker-compose down to shut down the containers.
|
||||
|
||||
### Without Docker
|
||||
If you run the tests of this package, please make sure you don't store anything in Redis @ 127.0.0.1:6379 db#14. The contents of this database are flushed everytime the tests are run.
|
||||
|
||||
Some tests are run only if the CI, TRAVIS and CONTINUOUS_INTEGRATION environment variables are set to true. This is to avoid things like bloating your MySQL instance with test databases.
|
||||
Some tests are run only if the `CONTINUOUS_INTEGRATION` or `DOCKER` environment variables are set to true. This is to avoid things like bloating your MySQL instance with test databases.
|
||||
|
|
|
|||
13
src/Exceptions/NotImplementedException.php
Normal file
13
src/Exceptions/NotImplementedException.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Stancl\Tenancy\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class NotImplementedException extends Exception
|
||||
{
|
||||
public function __construct($class, $method, $extra)
|
||||
{
|
||||
parent::__construct("The $class class does not implement the $method method. $extra");
|
||||
}
|
||||
}
|
||||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue