{{-- One paket of the Kelola Paket list: a one-line summary (name, price, quotas, days) that opens to the form: name, price, days and a quota per service (SMS / MMS / WA Business x LBA / Broadcast / Targeted), each with "Tanpa batas" (an unlimited quota, sent as null). $index, $paket (the API's paket, the sent values after a refused save, or [] for a new one), $open (show the form). --}} @php $field = "pakets[$index]"; $sentQuotas = (array) ($paket['quotas'] ?? []); // Unlimited: null from the API, or the ticked box after a refused save. $unlimited = array_keys(array_filter((array) ($paket['unlimited'] ?? []))) ?: array_keys(array_filter($sentQuotas, fn ($value) => $value === null)); $quotas = array_filter($sentQuotas, fn ($value) => $value !== null && $value !== ''); $isNew = empty($paket['id']); $summaryQuotas = collect(array_keys(\App\Support\PackageServices::LABELS)) ->filter(fn ($service) => in_array($service, $unlimited, true) || isset($quotas[$service])) ->map(fn ($service) => (in_array($service, $unlimited, true) ? 'Tanpa batas' : number_format((int) $quotas[$service], 0, ',', '.')).' '.\App\Support\PackageServices::label($service)) ->join(' + '); $summaryPrice = is_numeric($paket['price'] ?? null) ? 'Rp '.number_format((int) $paket['price'], 0, ',', '.') : '-'; @endphp
{{ $isNew && empty($paket['name']) ? 'Paket baru' : (($paket['name'] ?? '') ?: 'Paket tanpa nama') }} {{ $summaryPrice }} {{ $summaryQuotas ?: 'Belum ada kuota' }} {{ \App\Support\PackageServices::duration($paket['duration_days'] ?? null) }}
@unless($isNew)@endunless
@foreach($kinds as $kindLabel)@endforeach@foreach($channels as $channel => $channelLabel) @foreach($kinds as $kind => $kindLabel) @php $service = $channel.'_'.$kind; @endphp @php $isUnlimited = in_array($service, $unlimited, true); @endphp @endforeach @endforeach
Kuota penerima per layanan
Kuota (penerima){{ $kindLabel }}
{{ $channelLabel }}
@unless($isNew) @endunless