customers->resolveFor('order', $row['ordernum'] ?? $row['id'], (int) $row['userid']), date: $this->nullableDate($row['date'] ?? null), total: (int) round((float) $row['amount']), status: $this->mapStatus($row['status']), paymentMethod: $row['paymentmethod'] ?: null, note: $row['notes'] ?: null, clientIp: $row['ipaddress'] ?: null, createdAt: $this->nullableDate($row['date'] ?? null), ); } /** * orders.status: 0=pending, 1=completed, 2=cancelled, 3=processing. */ private function mapStatus(string $status): int { return match ($status) { 'Active', 'Completed' => 1, 'Cancelled', 'Fraud', 'Failed' => 2, 'Pending Activation', 'In Progress' => 3, default => 0, }; } /** * WHMCS has zero-dates ('0000-00-00...') and occasional bogus years, both * invalid for MySQL strict mode, so nullify anything before 1970. */ private function nullableDate(?string $value): ?string { if (! $value || (int) substr($value, 0, 4) < 1970) { return null; } return $value; } }