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 { $enum = ProductBillingCycle::tryFrom($cycle ?? '') ?? throw new \InvalidArgumentException("Unknown billing cycle: " . ($cycle ?? 'null')); return $enum === ProductBillingCycle::ONE_TIME ? 1 : $enum->months(); } }