connection = $connection; $this->databaseManager = $databaseManager; $this->dynamic = $dynamic; $this->encrypter = $encrypter; $this->repository = $repository; } /** * Create a new database host on the Panel. * * @param array $data * @return \Pterodactyl\Models\DatabaseHost * * @throws \Pterodactyl\Exceptions\Model\DataValidationException * @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException */ public function handle(array $data): DatabaseHost { $this->connection->beginTransaction(); $host = $this->repository->create([ 'password' => $this->encrypter->encrypt(array_get($data, 'password')), 'name' => array_get($data, 'name'), 'host' => array_get($data, 'host'), 'port' => array_get($data, 'port'), 'username' => array_get($data, 'username'), 'max_databases' => null, 'node_id' => array_get($data, 'node_id'), ]); // Confirm access using the provided credentials before saving data. $this->dynamic->set('dynamic', $host); $this->databaseManager->connection('dynamic')->select('SELECT 1 FROM dual'); $this->connection->commit(); return $host; } }