connection === null) { throw new NoConnectionSetException(static::class); } return DB::connection($this->connection); } public function setConnection(string $connection): void { $this->connection = $connection; } public function createDatabase(TenantWithDatabase $tenant): bool { $database = $tenant->database()->getName(); $charset = $this->database()->getConfig('charset'); $collation = $this->database()->getConfig('collation'); // todo check why these are not used return $this->database()->statement("CREATE DATABASE [{$database}]"); } public function deleteDatabase(TenantWithDatabase $tenant): bool { return $this->database()->statement("DROP DATABASE [{$tenant->database()->getName()}]"); } public function databaseExists(string $name): bool { return (bool) $this->database()->select("SELECT name FROM master.sys.databases WHERE name = '$name'"); } public function makeConnectionConfig(array $baseConfig, string $databaseName): array { $baseConfig['database'] = $databaseName; return $baseConfig; } }