'datetime', 'is_valid' => 'boolean', 'is_active' => 'boolean', 'actual_value' => 'array', ]; /** * Available DNS record types. */ public static function getRecordTypes(): array { return [ 'A' => 'A (IPv4 Address)', 'AAAA' => 'AAAA (IPv6 Address)', 'CNAME' => 'CNAME (Canonical Name)', 'MX' => 'MX (Mail Exchange)', 'TXT' => 'TXT (Text Record)', 'NS' => 'NS (Name Server)', 'SOA' => 'SOA (Start of Authority)', 'PTR' => 'PTR (Pointer)', 'SRV' => 'SRV (Service)', ]; } /** * Get the site that owns the DNS record. */ public function site(): BelongsTo { return $this->belongsTo(Site::class); } /** * Scope to filter active DNS records. */ public function scopeActive($query) { return $query->where('is_active', true); } /** * Scope to filter valid records. */ public function scopeValid($query) { return $query->where('is_valid', true); } /** * Scope to filter invalid records. */ public function scopeInvalid($query) { return $query->where('is_valid', false); } /** * Get status badge color. */ public function getStatusColorAttribute(): string { if ($this->is_valid === null) { return 'secondary'; } return $this->is_valid ? 'success' : 'danger'; } /** * Get status text. */ public function getStatusTextAttribute(): string { if ($this->is_valid === null) { return 'Unknown'; } return $this->is_valid ? 'Valid' : 'Invalid'; } /** * Get display name for the record. */ public function getDisplayNameAttribute(): string { return "{$this->record_type} - {$this->domain}"; } /** * Get formatted actual value for display. */ public function getFormattedActualValueAttribute(): ?string { if (!$this->actual_value) { return null; } if (is_array($this->actual_value)) { if (count($this->actual_value) === 1) { return $this->actual_value[0]; } return implode(', ', $this->actual_value); } return $this->actual_value; } }