1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 17:04:03 +00:00
This commit is contained in:
Samuel Štancl 2019-08-16 00:35:22 +02:00
parent 71e1c170bb
commit 68e0922444
4 changed files with 8 additions and 5 deletions

View file

@ -10,8 +10,9 @@ class DatabaseStorageDriver implements StorageDriver
public $useJson = false;
// todo use an instance of tenant model?
// todo write tests verifying that data is decoded and added to the array
public function identifyTenant(string $domain): array
public function identifyTenant(string $domain): array // todo returns data col
{
$id = $this->getTenantIdByDomain($domain);
if (! $id) {
@ -64,7 +65,7 @@ class DatabaseStorageDriver implements StorageDriver
public function getMany(string $uuid, array $keys): array
{
return Tenant::getMany($keys);
return Tenant::find($uuid)->getMany($keys);
}
public function put(string $uuid, string $key, $value)

View file

@ -77,7 +77,7 @@ class Tenant extends Model
$obj = json_decode($this->{$this->dataColumn()});
$obj->$key = $value;
$this->update([$this->getDataColumn() => json_encode($obj)]);
$this->update([$this->dataColumn() => json_encode($obj)]);
}
return $value;

View file

@ -203,7 +203,9 @@ final class TenantManager
*/
public function setTenant(array $tenant): array
{
$tenant = $this->jsonDecodeArrayValues($tenant);
if ($this->useJson()) {
$tenant = $this->jsonDecodeArrayValues($tenant);
}
$this->tenant = $tenant;

View file

@ -25,7 +25,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
Redis::connection('cache')->flushdb();
config(['database.default' => 'central']);
$this->loadLaravelMigrations();
$this->loadLaravelMigrations(['--database' => 'central']);
$this->loadMigrationsFrom(realpath(__DIR__ . '/../src/assets/migrations'));
if ($this->autoCreateTenant) {