@if (session('status'))
{{ session('status') }}
@endif
@if ($errors->any())
{{ $errors->first() }}
@endif
@php
$currentPid = (int) ($service->api_pid ?: data_get($service->whmcs_payload, 'pid', 0));
$formatCycle = fn ($cycle) => ucwords(str_replace(['_', '-'], ' ', (string) $cycle));
$displayPrice = function ($amount, $currency) {
if ($amount === null || $amount === '' || (float) $amount < 0) return null;
$amount = number_format((float) $amount, 2);
return strtoupper((string) $currency) === 'USD' ? '$'.$amount.' USD' : strtoupper((string) $currency).' '.$amount;
};
$availableCycles = function ($product) use ($displayPrice, $formatCycle) {
$rows = [];
foreach ((array) data_get($product, 'pricing', []) as $currency => $cyclePrices) {
if (! is_array($cyclePrices)) continue;
foreach ($cyclePrices as $cycle => $price) {
if (in_array($cycle, ['prefix','suffix','msetupfee','qsetupfee','ssetupfee','asetupfee','bsetupfee','tsetupfee'], true)) continue;
$label = $displayPrice($price, $currency);
if ($label !== null) $rows[(string) $cycle] = $formatCycle($cycle).' · '.$label;
}
}
return $rows;
};
$descriptionLines = function ($description) {
$html = str_ireplace(['
', '
', '
', '', '', '
'], "\n", (string) $description);
$text = html_entity_decode(strip_tags($html), ENT_QUOTES | ENT_HTML5, 'UTF-8');
return collect(preg_split('/\r\n|\r|\n/', $text))
->map(fn ($line) => trim(preg_replace('/^[\s•\-–—✓✔]+/u', '', (string) $line)))
->filter(fn ($line) => $line !== '' && $line !== '-----------------------------------')
->unique()->values();
};
@endphp