diff --git a/app/Livewire/Datatable/Loyalty/VouchersTable.php b/app/Livewire/Datatable/Loyalty/VouchersTable.php
index 006012d..f2c17a5 100644
--- a/app/Livewire/Datatable/Loyalty/VouchersTable.php
+++ b/app/Livewire/Datatable/Loyalty/VouchersTable.php
@@ -41,55 +41,64 @@ public function columns(): array
->sortable(),
Column::make('Min. Belanja', 'min_purchase')
- ->format(fn($value) => formatCurrencyNumber($value, 'Rp'))
+ ->format(fn ($value) => formatCurrencyNumber($value, 'Rp'))
->searchable()
->sortable(),
ArrayColumn::make('Tier')
->data(
- fn($value, $row) => $row->tiers->pluck('name')->toArray() ?: ['Semua Tier']
+ fn ($value, $row) => $row->tiers->pluck('name')->toArray() ?: ['Semua Tier']
)
- ->outputFormat(fn($index, $value) => Blade::render('' . $value . ''))
+ ->outputFormat(fn ($index, $value) => Blade::render(''.$value.''))
->flexRow(['class' => 'gap-2 flex-wrap']),
Column::make('Jumlah Diskon', 'discount_amount')
- ->label(fn($row, $column) => formatDiscount($row->discount_amount, $row->type))
+ ->label(fn ($row, $column) => formatDiscount($row->discount_amount, $row->type))
->searchable()
->sortable(),
Column::make('Maks. Diskon')
- ->label(fn($row, $column) => formatCurrencyNumber($row->max_discount, 'Rp'))
+ ->label(fn ($row, $column) => formatCurrencyNumber($row->max_discount, 'Rp'))
->searchable()
->sortable(),
- Column::make('Kuota', 'quota')
- ->format(fn($value) => $value ? formatCurrencyNumber($value) : 'Tidak Terbatas')
- ->searchable()
- ->sortable(),
+ Column::make('Kuota / Sisa Voucher')
+ ->label(function ($record) {
+ $quota = $record->quota
+ ? formatCurrencyNumber($record->quota)
+ : 'Tidak Terbatas';
- Column::make('Sisa Voucher', 'available_count')
- ->format(fn($value) => $value ? formatCurrencyNumber($value) : 'Tidak Terbatas')
+ $available = $record->available_count
+ ? formatCurrencyNumber($record->available_count)
+ : 'Tidak Terbatas';
+
+ return "{$quota} / {$available}";
+ })
->searchable()
->sortable(),
Column::make('Batas Per Pembali', 'limit_per_user')
- ->format(fn($value) => $value ? $value : 'Tidak Terbatas')
+ ->format(fn ($value) => $value ? $value : 'Tidak Terbatas')
->searchable()
->sortable(),
ArrayColumn::make('Outlet')
->data(
- fn($value, $row) => $row->outlets->map(fn($outlet) => [
+ fn ($value, $row) => $row->outlets->map(fn ($outlet) => [
'name' => $outlet->name,
'stock' => formatCurrencyNumber($outlet->pivot->stock, ''),
])->toArray()
)
- ->outputFormat(fn($index, $value) => Blade::render('
+ ->outputFormat(fn ($index, $value) => Blade::render('
{{ $value["name"] }}
', ['value' => $value]))
->flexRow(['class' => 'gap-2 flex-wrap']),
+ Column::make('Visibilitas', 'is_show')
+ ->label(fn ($row, $column) => Blade::render(''.$row->is_show->label().''))
+ ->html(),
+
Column::make('Tanggal')
->label(function ($row) {
$startDate = formatDateLocalized($row->start_date);
@@ -141,11 +150,11 @@ public function columns(): array
public function builder(): Builder
{
- return Voucher::select('vouchers.id', 'vouchers.name', 'code', 'tags', 'min_purchase', 'discount_amount', 'max_discount', 'quota', 'available_count', 'limit_per_user', 'start_date', 'end_date', 'type', 'vouchers.created_at')
+ return Voucher::select('vouchers.id', 'vouchers.name', 'code', 'tags', 'min_purchase', 'discount_amount', 'max_discount', 'quota', 'available_count', 'limit_per_user', 'start_date', 'end_date', 'type', 'is_show', 'vouchers.created_at')
->with(['outlets', 'tiers'])
->whereHas(
'outlets',
- fn($q) => $q->whereIn('outlets.id', auth()->user()->outlets()->pluck('outlets.id'))
+ fn ($q) => $q->whereIn('outlets.id', auth()->user()->outlets()->pluck('outlets.id'))
);
}
}
diff --git a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
index a5c71f4..204fdad 100644
--- a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
+++ b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
@@ -2,6 +2,7 @@
namespace App\Livewire\Forms\Studio\Loyalty;
+use App\Enums\IsShow;
use App\Enums\VoucherType;
use App\Models\Voucher;
use App\Rules\UnsignedInteger;
@@ -41,6 +42,8 @@ class VoucherForm extends Form
public array $outlet_ids = [];
+ public int $is_show = 1;
+
public function rules(): array
{
return [
@@ -79,6 +82,7 @@ public function rules(): array
'tier_ids.*' => Rule::exists('tiers', 'id'),
'outlet_ids' => ['required', 'array', 'min:1'],
'outlet_ids.*' => Rule::exists('outlets', 'id'),
+ 'is_show' => ['required', Rule::in(IsShow::values())],
];
}
@@ -100,6 +104,7 @@ public function validationAttributes(): array
'tier_ids.*' => 'tier',
'outlet_ids' => 'outlet',
'outlet_ids.*' => 'outlet',
+ 'is_show' => 'visibilitas',
];
}
@@ -121,7 +126,8 @@ public function setVoucher(Voucher $voucher): void
$this->summary = $this->voucher->summary;
$this->start_date = $this->voucher->start_date;
$this->end_date = $this->voucher->end_date;
-
+ $this->is_show = $this->voucher->is_show->value;
+
$this->tier_ids = $this->voucher->tiers->pluck('id')->toArray();
$this->outlet_ids = $this->voucher->outlets->pluck('id')->toArray();
@@ -178,6 +184,7 @@ private function prepareSavedData(): array
'summary' => $this->summary,
'start_date' => $this->start_date,
'end_date' => $this->end_date,
+ 'is_show' => $this->is_show,
];
}
}
diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php
index 0b99e24..10522a5 100644
--- a/app/Models/Voucher.php
+++ b/app/Models/Voucher.php
@@ -2,6 +2,7 @@
namespace App\Models;
+use App\Enums\IsShow;
use App\Enums\VoucherType;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
@@ -28,6 +29,7 @@ protected function casts(): array
'quota' => 'int',
'available_count' => 'int',
'limit_per_user' => 'int',
+ 'is_show' => IsShow::class,
];
}
diff --git a/resources/views/livewire/studio/loyalty/voucher/form.blade.php b/resources/views/livewire/studio/loyalty/voucher/form.blade.php
index 9b266e0..93da25e 100644
--- a/resources/views/livewire/studio/loyalty/voucher/form.blade.php
+++ b/resources/views/livewire/studio/loyalty/voucher/form.blade.php
@@ -154,6 +154,17 @@
+
+ Visibilitas *
+
+ @foreach (\App\Enums\IsShow::cases() as $item)
+
+ {{ $item->label() }}
+
+ @endforeach
+
+
+