connection->transaction(function () use ($data) { $host = DatabaseHost::query()->create([ 'password' => 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' => array_get($data, 'max_databases'), ]); $host->nodes()->sync(array_get($data, 'node_ids', [])); // Confirm access using the provided credentials before saving data. $this->dynamic->set('dynamic', $host); $this->databaseManager->connection('dynamic')->getPdo(); return $host; }); } }