info('Check invoice due dates'); Log::info('Check invoice due dates'); try { $today = Carbon::today(); // Find invoices with payment_status 'issued' and due_date <= today $invoices = Invoice::where('payment_status', 'issued') ->whereDate('due_date', '<=', $today) ->get(); foreach ($invoices as $invoice) { $invoice->update(['payment_status' => 'due']); $this->info("Updated invoice {$invoice->nr} to 'due' status"); } $this->info("Checked {$invoices->count()} invoices for due dates."); } catch (\Exception $e) { $this->error("Error in CheckInvoiceDueDatesJob: " . $e->getMessage()); } return 0; } }