OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace Leantime\Core\Database;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class DatabaseManager
{
/**
* Switch the database connection to use the given configuration.
*
* @param array $config Database configuration with keys: dbHost, dbDatabase, dbUser, dbPassword
*/
public static function switchConnection(array $config): void
{
try {
$connectionName = config('database.default', 'mysql');
// Purge existing connections
DB::purge($connectionName);
// Update the configuration
config([
"database.connections.{$connectionName}.host" => $config['dbHost'],
"database.connections.{$connectionName}.database" => $config['dbDatabase'],
"database.connections.{$connectionName}.username" => $config['dbUser'],
"database.connections.{$connectionName}.password" => $config['dbPassword'],
]);
// Reconnect with new configuration
DB::reconnect($connectionName);
// Verify connection
DB::connection($connectionName)->getPdo();
} catch (\Exception $e) {
Log::error('Database connection failed: '.$e->getMessage());
throw new \RuntimeException('Failed to establish database connection: '.$e->getMessage());
}
}
}