'datetime', 'is_valid' => 'boolean', 'is_active' => 'boolean', 'url_count' => 'integer', ]; public function site(): BelongsTo { return $this->belongsTo(Site::class); } /** * Check if sitemap has errors */ public function hasErrors(): bool { return !$this->is_valid || !empty($this->last_error); } /** * Get the status badge color */ public function getStatusBadgeClass(): string { if (!$this->last_checked_at) { return 'bg-secondary'; } return $this->is_valid ? 'bg-success' : 'bg-danger'; } /** * Get the status text */ public function getStatusText(): string { if (!$this->last_checked_at) { return 'Not Checked'; } return $this->is_valid ? 'Valid' : 'Invalid'; } /** * Mark sitemap as valid */ public function markAsValid(?int $urlCount = null): void { $this->update([ 'is_valid' => true, 'last_error' => null, 'last_checked_at' => now(), 'url_count' => $urlCount, ]); } /** * Mark sitemap as invalid */ public function markAsInvalid(string $error): void { $this->update([ 'is_valid' => false, 'last_error' => $error, 'last_checked_at' => now(), ]); } }