'boolean', 'metadata' => 'array', ]; public function source(): BelongsTo { return $this->belongsTo(JobSource::class, 'job_source_id'); } /** * Scope to get only successful logs */ public function scopeSuccessful($query) { return $query->where('success', true); } /** * Scope to get only failed logs */ public function scopeFailed($query) { return $query->where('success', false); } /** * Scope to get logs within a date range */ public function scopeWithinDays($query, int $days) { return $query->where('created_at', '>=', now()->subDays($days)); } /** * Get total jobs processed */ public function getTotalJobsProcessedAttribute(): int { return $this->jobs_created + $this->jobs_updated + $this->jobs_skipped; } }