Voucher

Kelola program voucher, kode, dan pantau pemakaiannya.

@can('vouchers.manage') Buat Program @endcan @can('vouchers.view') Performa Riwayat Pakai @endcan
@php $now = now(); $countRunning = 0; $countExpiring = 0; $countQuotaLow = 0; foreach ($campaigns as $c) { $used = (int) ($c->codes_sum_times_redeemed ?? 0); $limit = $c->usage_limit_total === null ? null : (int) $c->usage_limit_total; $remaining = $limit === null ? null : max(0, $limit - $used); $isRunning = (bool) $c->is_active && (! $c->starts_at || $c->starts_at->lte($now)) && (! $c->ends_at || $c->ends_at->gte($now)); $expiresSoon = $c->ends_at ? $c->ends_at->lte($now->copy()->addDays($daysBeforeExpiry)) : false; $quotaLow = $remaining !== null ? $remaining <= $quotaThreshold : false; if ($isRunning) $countRunning++; if ($expiresSoon) $countExpiring++; if ($quotaLow) $countQuotaLow++; } @endphp

Program (di halaman ini)

{{ number_format((int) $campaigns->count(), 0, ',', '.') }}

Sedang berjalan

{{ number_format((int) $countRunning, 0, ',', '.') }}

Akan berakhir ({{ (int) $daysBeforeExpiry }} hari)

{{ number_format((int) $countExpiring, 0, ',', '.') }}

Kuota menipis (≤ {{ (int) $quotaThreshold }})

{{ number_format((int) $countQuotaLow, 0, ',', '.') }}

@forelse ($campaigns as $c) @php $used = (int) ($c->codes_sum_times_redeemed ?? 0); $limit = $c->usage_limit_total === null ? null : (int) $c->usage_limit_total; $remaining = $limit === null ? null : max(0, $limit - $used); $isRunning = (bool) $c->is_active && (! $c->starts_at || $c->starts_at->lte(now())) && (! $c->ends_at || $c->ends_at->gte(now())); $expiresSoon = $c->ends_at ? $c->ends_at->lte(now()->addDays($daysBeforeExpiry)) : false; $quotaLow = $remaining !== null ? $remaining <= $quotaThreshold : false; @endphp @empty @endforelse
Program Periode Diskon Kode Dipakai Diskon Total Kuota Aksi

{{ $c->name }}

{{ $isRunning ? 'Berjalan' : ((bool) $c->is_active ? 'Aktif' : 'Nonaktif') }} @if ($expiresSoon) Akan berakhir @endif @if ($quotaLow) Kuota Menipis @endif

{{ $c->starts_at ? $c->starts_at->format('d M Y') : '-' }} - {{ $c->ends_at ? $c->ends_at->format('d M Y') : '-' }}

{{ $c->is_member_only ? 'Khusus Member' : 'Semua Pengunjung' }}

Diskon: {{ $c->discount_type === 'percent' ? ($c->discount_value.'%') : ('Rp'.number_format((int) $c->discount_value, 0, ',', '.')) }}

@if ($c->discount_type === 'percent' && $c->max_discount_amount !== null)

Batas: Rp{{ number_format((int) $c->max_discount_amount, 0, ',', '.') }}

@endif

Minimal belanja: {{ $c->min_eligible_subtotal !== null ? 'Rp'.number_format((int) $c->min_eligible_subtotal, 0, ',', '.') : '-' }}

{{ number_format((int) ($c->codes_count ?? 0), 0, ',', '.') }}

{{ number_format((int) ($c->redemptions_count ?? 0), 0, ',', '.') }}

{{ (int) ($c->redemptions_sum_discount_amount ?? 0) > 0 ? 'Rp'.number_format((int) $c->redemptions_sum_discount_amount, 0, ',', '.') : '-' }}

{{ $limit === null ? '∞' : (number_format($used, 0, ',', '.').' / '.number_format($limit, 0, ',', '.')) }}

@if ($remaining !== null)

Sisa: {{ number_format($remaining, 0, ',', '.') }}

@endif
@can('vouchers.manage') Kode Ubah @endcan
{{ $campaigns->links('livewire.pagination.admin') }}