table('ticket_master') ->where('id', $claimId) ->update(['tpa_claim_push_logs' => "[{$started}] Claim push started\n"]); } } if (!function_exists('tpa_claim_push_log')) { /** * Write to application log and append the same line to ticket_master.tpa_claim_push_logs. */ function tpa_claim_push_log($claimId, string $message, string $level = 'error'): void { log_message($level, $message); if ($claimId === null || $claimId === '') { return; } $timestamp = date('Y-m-d H:i:s'); $line = "[{$timestamp}] {$message}\n"; $db = \Config\Database::connect(); $row = $db->table('ticket_master') ->select('tpa_claim_push_logs') ->where('id', $claimId) ->get() ->getRowArray(); $existing = $row['tpa_claim_push_logs'] ?? ''; $db->table('ticket_master') ->where('id', $claimId) ->update(['tpa_claim_push_logs' => $existing . $line]); } }