belongsTo(Node::class); } public function os() { return $this->belongsTo(OS::class); } public function ipAddresses() { return $this->hasMany(IPAddress::class); } public function service() { return $this->belongsTo(Service::class); } public function primaryIpv4() { return $this->belongsTo(IPAddress::class, 'primary_ipv4'); } public function primaryIpv6() { return $this->belongsTo(IPAddress::class, 'primary_ipv6'); } public function statistics() { return $this->hasMany(ServerStatistics::class); } public function setPasswordAttribute(?string $value): void { if ($value === null || $value === '') { $this->attributes['password'] = null; return; } $this->attributes['password'] = Crypt::encryptString($value); } public function getPasswordAttribute(?string $value): ?string { if ($value === null || $value === '') { return null; } try { return Crypt::decryptString($value); } catch (DecryptException) { // Refuse to expose undecipherable values to callers. report(new \RuntimeException('Failed to decrypt stored Proxmox server password.')); return null; } } public function hasStoredPassword(): bool { $rawPassword = $this->getRawOriginal('password'); return is_string($rawPassword) && trim($rawPassword) !== ''; } }