connection->transaction(function () use ($data) { $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'); return $host; }); } }