get(Setting::FailedJobRetentionDays); // 0 means keep indefinitely — an explicit choice for somebody who // treats a failed job as evidence rather than as debris. if ($days <= 0) { $this->info('Failed job retention is disabled; nothing pruned.'); return self::SUCCESS; } // Both providers this application can be configured with implement // it; the guard is here because the interface it is declared // against does not require it, and a queue driver that cannot // prune should say so rather than fail obscurely. if (! $failer instanceof PrunableFailedJobProvider) { $this->warn('This queue failure store cannot be pruned; nothing done.'); return self::SUCCESS; } $deleted = $failer->prune(now()->subDays($days)); $this->info("Pruned {$deleted} failed jobs older than {$days} days."); return self::SUCCESS; } }