Replace DatabaseHost Repository
This commit is contained in:
parent
860b2d890b
commit
9001755e10
10 changed files with 29 additions and 74 deletions
|
@ -5,7 +5,6 @@ namespace Pterodactyl\Extensions;
|
|||
use Pterodactyl\Models\DatabaseHost;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Illuminate\Config\Repository as ConfigRepository;
|
||||
use Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface;
|
||||
|
||||
class DynamicDatabaseConnection
|
||||
{
|
||||
|
@ -18,20 +17,18 @@ class DynamicDatabaseConnection
|
|||
*/
|
||||
public function __construct(
|
||||
protected ConfigRepository $config,
|
||||
protected Encrypter $encrypter,
|
||||
protected DatabaseHostRepositoryInterface $repository
|
||||
protected Encrypter $encrypter
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a dynamic database connection entry to the runtime config.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function set(string $connection, DatabaseHost|int $host, string $database = 'mysql'): void
|
||||
{
|
||||
if (!$host instanceof DatabaseHost) {
|
||||
$host = $this->repository->find($host);
|
||||
$host = DatabaseHost::query()->findOrFail($host);
|
||||
}
|
||||
|
||||
$this->config->set('database.connections.' . $connection, [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue