diff --git a/assets/config.php b/assets/config.php index d064e50b..c5c89c5b 100644 --- a/assets/config.php +++ b/assets/config.php @@ -25,7 +25,7 @@ return [ // 'localhost', ], 'database' => [ - 'based_on' => 'mysql', // The connection that will be used as a base for the dynamically created tenant connection. + 'based_on' => null, // The connection that will be used as a base for the dynamically created tenant connection. // todo2 test this 'prefix' => 'tenant', 'suffix' => '', ], diff --git a/src/Commands/Migrate.php b/src/Commands/Migrate.php index 7f68e37b..3eb4cf3c 100644 --- a/src/Commands/Migrate.php +++ b/src/Commands/Migrate.php @@ -56,7 +56,7 @@ class Migrate extends MigrateCommand // See Illuminate\Database\Migrations\DatabaseMigrationRepository::getConnection. // Database connections are cached by Illuminate\Database\ConnectionResolver. $this->input->setOption('database', 'tenant'); - tenancy()->initialize($tenant); // todo2 test that this works with multiple tenants with MySQL + tenancy()->initialize($tenant); // todo3 test that this works with multiple tenants with MySQL // Migrate parent::handle(); diff --git a/src/DatabaseManager.php b/src/DatabaseManager.php index eca1cfcf..91a76917 100644 --- a/src/DatabaseManager.php +++ b/src/DatabaseManager.php @@ -78,7 +78,7 @@ class DatabaseManager */ public function getBaseConnection(string $connectionName): string { - return $connectionName + return ($connectionName !== 'tenant' ? $connectionName : null) // 'tenant' is not a specific connection, it's the default ?? $this->app['config']['tenancy.database.based_on'] ?? $this->originalDefaultConnectionName; // tenancy.database.based_on === null => use the default connection } @@ -87,9 +87,9 @@ class DatabaseManager * Get the driver of a database connection. * * @param string $connectionName - * @return string + * @return string|null */ - public function getDriver(string $connectionName): string + public function getDriver(string $connectionName): ?string { return $this->app['config']["database.connections.$connectionName.driver"]; } diff --git a/src/StorageDrivers/Database/DatabaseStorageDriver.php b/src/StorageDrivers/Database/DatabaseStorageDriver.php index 3fa5c058..7e89cb69 100644 --- a/src/StorageDrivers/Database/DatabaseStorageDriver.php +++ b/src/StorageDrivers/Database/DatabaseStorageDriver.php @@ -16,7 +16,7 @@ use Stancl\Tenancy\Tenant; class DatabaseStorageDriver implements StorageDriver { - // todo2 write tests verifying that data is decoded and added to the array + // todo4 write tests verifying that data is decoded and added to the array /** @var Application */ protected $app;