mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 14:14:03 +00:00
wip
This commit is contained in:
parent
71e1c170bb
commit
68e0922444
4 changed files with 8 additions and 5 deletions
|
|
@ -10,8 +10,9 @@ class DatabaseStorageDriver implements StorageDriver
|
||||||
public $useJson = false;
|
public $useJson = false;
|
||||||
|
|
||||||
// todo use an instance of tenant model?
|
// 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);
|
$id = $this->getTenantIdByDomain($domain);
|
||||||
if (! $id) {
|
if (! $id) {
|
||||||
|
|
@ -64,7 +65,7 @@ class DatabaseStorageDriver implements StorageDriver
|
||||||
|
|
||||||
public function getMany(string $uuid, array $keys): array
|
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)
|
public function put(string $uuid, string $key, $value)
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class Tenant extends Model
|
||||||
$obj = json_decode($this->{$this->dataColumn()});
|
$obj = json_decode($this->{$this->dataColumn()});
|
||||||
$obj->$key = $value;
|
$obj->$key = $value;
|
||||||
|
|
||||||
$this->update([$this->getDataColumn() => json_encode($obj)]);
|
$this->update([$this->dataColumn() => json_encode($obj)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,9 @@ final class TenantManager
|
||||||
*/
|
*/
|
||||||
public function setTenant(array $tenant): array
|
public function setTenant(array $tenant): array
|
||||||
{
|
{
|
||||||
|
if ($this->useJson()) {
|
||||||
$tenant = $this->jsonDecodeArrayValues($tenant);
|
$tenant = $this->jsonDecodeArrayValues($tenant);
|
||||||
|
}
|
||||||
|
|
||||||
$this->tenant = $tenant;
|
$this->tenant = $tenant;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
Redis::connection('cache')->flushdb();
|
Redis::connection('cache')->flushdb();
|
||||||
|
|
||||||
config(['database.default' => 'central']);
|
config(['database.default' => 'central']);
|
||||||
$this->loadLaravelMigrations();
|
$this->loadLaravelMigrations(['--database' => 'central']);
|
||||||
$this->loadMigrationsFrom(realpath(__DIR__ . '/../src/assets/migrations'));
|
$this->loadMigrationsFrom(realpath(__DIR__ . '/../src/assets/migrations'));
|
||||||
|
|
||||||
if ($this->autoCreateTenant) {
|
if ($this->autoCreateTenant) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue