Invoice::where('invoice_number', $number)->exists(), default => Order::where('order_num', $number)->exists(), }; } while ($exists); return $number; } /** * @throws \InvalidArgumentException */ public static function cycleToMonths(?string $cycle): int { $months = BillingCycleCatalog::monthsFor($cycle) ?? throw new \InvalidArgumentException("Unknown billing cycle: " . ($cycle ?? 'null')); return $months ?: 1; } }