Start 2.0 development

Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
This commit is contained in:
robert dennis
2026-10-05 18:10:18 -04:00
co-authored by Anthony Sky Mulley
parent 98079a0166
commit 6c0413e39b
2764 changed files with 176950 additions and 72961 deletions
+15 -13
View File
@@ -1,17 +1,21 @@
<?php
declare(strict_types=1);
namespace Pterodactyl\Extensions;
use Pterodactyl\Models\DatabaseHost;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Pterodactyl\Models\DatabaseHost;
class DynamicDatabaseConnection
{
public const DB_CHARSET = 'utf8';
public const DB_COLLATION = 'utf8_unicode_ci';
public const DB_DRIVER = 'mysql';
public const string DB_CHARSET = 'utf8';
public const string DB_COLLATION = 'utf8_unicode_ci';
public const string DB_DRIVER = 'mysql';
/**
* DynamicDatabaseConnection constructor.
@@ -19,22 +23,20 @@ class DynamicDatabaseConnection
public function __construct(
protected ConfigRepository $config,
protected Encrypter $encrypter,
protected DatabaseHostRepositoryInterface $repository,
) {
}
) {}
/**
* Adds a dynamic database connection entry to the runtime config.
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws ModelNotFoundException
*/
public function set(string $connection, DatabaseHost|int $host, string $database = 'mysql'): void
{
if (!$host instanceof DatabaseHost) {
$host = $this->repository->find($host);
if (! $host instanceof DatabaseHost) {
$host = DatabaseHost::query()->findOrFail($host);
}
$this->config->set('database.connections.' . $connection, [
$this->config->set('database.connections.'.$connection, [
'driver' => self::DB_DRIVER,
'host' => $host->host,
'port' => $host->port,