mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
Default to default DB
This commit is contained in:
parent
29c8d5dab4
commit
f87c2b69ec
2 changed files with 13 additions and 1 deletions
|
|
@ -30,7 +30,7 @@ class Tenant extends Model
|
||||||
|
|
||||||
public function getConnectionName()
|
public function getConnectionName()
|
||||||
{
|
{
|
||||||
return config('tenancy.storage.db.connection', 'central');
|
return config('tenancy.storage.db.connection') ?: config('database.default');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllTenants(array $uuids)
|
public static function getAllTenants(array $uuids)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Stancl\Tenancy\Tests;
|
||||||
|
|
||||||
use Stancl\Tenancy\StorageDrivers\RedisStorageDriver;
|
use Stancl\Tenancy\StorageDrivers\RedisStorageDriver;
|
||||||
use Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver;
|
use Stancl\Tenancy\StorageDrivers\DatabaseStorageDriver;
|
||||||
|
use Stancl\Tenancy\Tenant;
|
||||||
|
|
||||||
class TenantStorageTest extends TestCase
|
class TenantStorageTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
@ -140,4 +141,15 @@ class TenantStorageTest extends TestCase
|
||||||
tenancy()->put('string', 'foo');
|
tenancy()->put('string', 'foo');
|
||||||
$this->assertSame('string', \gettype(tenancy()->get('string')));
|
$this->assertSame('string', \gettype(tenancy()->get('string')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function tenant_model_uses_correct_connection()
|
||||||
|
{
|
||||||
|
config(['tenancy.storage.db.connection' => 'foo']);
|
||||||
|
$this->assertSame('foo', (new Tenant)->getConnectionName());
|
||||||
|
|
||||||
|
config(['tenancy.storage.db.connection' => null]);
|
||||||
|
config(['database.default' => 'foobar']);
|
||||||
|
$this->assertSame('foobar', (new Tenant)->getConnectionName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue