0, 'paid' => 0]; } $pending = SettlementBatch::query() ->where('status', SettlementBatchStatus::PendingReview->value) ->orderBy('id') ->get(); foreach ($pending as $batch) { try { $this->workflow->approveBySystem($batch, 'auto approve on draw tick'); $approved++; } catch (\Throwable $e) { report($e); continue; } if (! (bool) LotterySettings::get('settlement.auto_payout_on_tick', true)) { continue; } try { $this->workflow->payout($batch->fresh()); $paid++; AuditLogger::recordForSystem( moduleCode: 'settlement', actionCode: 'auto_payout', targetType: 'settlement_batch', targetId: (string) $batch->id, afterJson: ['draw_id' => (int) $batch->draw_id], ); } catch (\Throwable $e) { report($e); } } return ['approved' => $approved, 'paid' => $paid]; } }