is_string($value) && blank($value) ? null : $value, $validated); $extensions = ValidatedExtensionValues::of($input['extensions'] ?? null); // A host given no node becomes global, and a blank password keeps the stored one. $attributes = [...Arr::except($validated, 'password'), 'node_id' => $validated['node_id'] ?? null]; if (isset($validated['password'])) { $attributes['password'] = Crypt::encrypt($validated['password']); } // Confirm access using the new credentials before saving them. $host->fill($attributes); $this->dynamic->set('dynamic', $host); DB::connection('dynamic')->select('SELECT 1 FROM dual'); // The host row and its extension values are written together so a failing // extension cannot leave a host behind without them. return DB::transaction(function () use ($host, $extensions): DatabaseHost { $host->save(); $this->extensions->save($host, $extensions); return $host; }); } }