@forelse($packages as $package)
@php
$priceStr = trim($package->price);
// Ganti koma dengan titik untuk standarisasi decimal
$priceStr = str_replace(',', '.', $priceStr);
$dotCount = substr_count($priceStr, '.');
if ($dotCount === 1 && strlen($priceStr) <= 5) {
// Seperti "2.5" atau "3.5"
$priceVal = (float) $priceStr * 1000000;
} elseif ($dotCount >= 1) {
// Seperti "2.500.000"
$priceVal = (float) str_replace('.', '', $priceStr);
} else {
// Seperti "3" atau "4"
$priceVal = (float) $priceStr;
if ($priceVal < 100) {
$priceVal = $priceVal * 1000000;
}
}
// Dapatkan jumlah tenor cicilan dari string payment_terms (misal: "3x" -> 3)
$installments = 3;
if (preg_match('/(\d+)x/', strip_tags($package->payment_terms), $matches)) {
$installments = (int) $matches[1];
}
// Hitung nominal cicilan per bulan
$monthlyVal = (int) round($priceVal / $installments);
$monthlyFormatted = 'Rp ' . number_format($monthlyVal, 0, ',', '.');
@endphp
@if($package->is_popular)
Paling Diminati
@endif
@if(is_array($package->features))
@foreach($package->features as $feature)
-
@if(isset($feature['is_active']) && !$feature['is_active'])
@else
@endif
{!! $feature['text'] !!}
@endforeach
@endif
@empty
Data paket harga belum ditambahkan di dashboard admin.
@endforelse