diff --git a/app/Enums/IsShow.php b/app/Enums/IsShow.php
new file mode 100644
index 0000000..eabfe17
--- /dev/null
+++ b/app/Enums/IsShow.php
@@ -0,0 +1,30 @@
+ 'Ditampilkan',
+ self::HIDDEN => 'Disembunyikan',
+ };
+ }
+
+ public function color()
+ {
+ return match ($this) {
+ self::SHOW => 'emerald',
+ self::HIDDEN => 'red',
+ };
+ }
+}
diff --git a/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php b/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php
index 9c6e8ab..80b173f 100644
--- a/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php
+++ b/app/Livewire/Datatable/Studio/Loyalty/VouchersTable.php
@@ -36,6 +36,10 @@ public function columns(): array
})
->html(),
+ Column::make('Tags', 'tags')
+ ->searchable()
+ ->sortable(),
+
Column::make('Min. Belanja', 'min_purchase')
->format(fn ($value) => currency($value, 'Rp'))
->searchable()
diff --git a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
index b241c49..e5624ad 100644
--- a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
+++ b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php
@@ -17,6 +17,8 @@ class VoucherForm extends Form
public string $code = '';
+ public string $tags = '';
+
public string $type = '1';
public string $discount_amount = '';
@@ -29,6 +31,8 @@ class VoucherForm extends Form
public ?string $limit_per_user = null;
+ public string $summary = '';
+
public string $start_date = '';
public ?string $end_date = null;
@@ -46,6 +50,7 @@ public function rules(): array
'alpha_num',
Rule::unique('vouchers', 'code')->ignore($this->voucher),
],
+ 'tags' => ['required', 'string', 'max:20'],
'type' => ['required', Rule::in(VoucherType::values())],
'discount_amount' => [
'required',
@@ -65,6 +70,7 @@ public function rules(): array
],
'quota' => ['nullable', new UnsignedInteger],
'limit_per_user' => ['nullable', new UnsignedInteger],
+ 'summary' => ['required', 'string', 'max:200'],
'start_date' => ['required', 'date', 'after:yesterday'],
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
'outlet_ids' => ['required', 'array', 'min:1'],
@@ -81,6 +87,7 @@ public function validationAttributes(): array
'max_discount' => 'maks. diskon',
'quota' => 'kuota',
'limit_per_user' => 'limit per user',
+ 'summary' => 'summary',
'type' => 'Tipe',
'discount_amount' => 'Jumlah Diskon',
'start_date' => 'tanggal mulai',
@@ -98,12 +105,14 @@ public function setVoucher(Voucher $voucher)
$this->name = $this->voucher->name;
$this->code = $this->voucher->code;
+ $this->summary = $this->voucher->summary;
$this->type = $this->voucher->type->value;
$this->discount_amount = replaceCurrency($this->voucher->discount_amount);
$this->min_purchase = replaceCurrency($this->voucher->min_purchase);
$this->max_discount = replaceCurrency($this->voucher->max_discount);
$this->quota = $this->voucher->quota;
$this->limit_per_user = $this->voucher->limit_per_user;
+ $this->summary = $this->voucher->summary;
$this->start_date = $this->voucher->start_date;
$this->end_date = $this->voucher->end_date;
@@ -141,6 +150,7 @@ private function prepareSavedData()
return [
'name' => $this->name,
'code' => $this->code,
+ 'tags' => $this->tags,
'type' => $this->type,
'discount_amount' => replaceCurrency($this->discount_amount),
'min_purchase' => replaceCurrency($this->min_purchase),
@@ -148,6 +158,7 @@ private function prepareSavedData()
'quota' => $this->quota,
'available_count' => $this->quota,
'limit_per_user' => $this->limit_per_user,
+ 'summary' => $this->summary,
'start_date' => $this->start_date,
'end_date' => $this->end_date,
];
diff --git a/database/migrations/2025_09_25_125559_create_vouchers_table.php b/database/migrations/2025_09_25_125559_create_vouchers_table.php
index 1d94dfb..032b52e 100644
--- a/database/migrations/2025_09_25_125559_create_vouchers_table.php
+++ b/database/migrations/2025_09_25_125559_create_vouchers_table.php
@@ -1,5 +1,6 @@
string('name', 50);
$table->string('code', 20)->unique();
$table->enum('type', [VoucherType::values()])->default(VoucherType::PERCENTAGE)->comment(VoucherType::comment());
+ $table->string('tags', 20);
+ $table->string('summary', 200);
$table->unsignedInteger('discount_amount');
$table->unsignedInteger('min_purchase')->nullable();
$table->unsignedInteger('max_discount')->nullable();
$table->unsignedInteger('quota')->nullable();
- $table->unsignedInteger('available_count')->nullable();
+ $table->unsignedInteger('available_count')->default(0);
$table->unsignedInteger('limit_per_user')->nullable();
$table->date('start_date');
$table->date('end_date')->nullable();
+ $table->enum('is_show', [IsShow::values()])->default(IsShow::SHOW)->comment(IsShow::comment());
$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
$table->softDeletes();
diff --git a/database/seeders/VoucherSeeder.php b/database/seeders/VoucherSeeder.php
index 16db2fe..9427ce3 100644
--- a/database/seeders/VoucherSeeder.php
+++ b/database/seeders/VoucherSeeder.php
@@ -16,6 +16,8 @@ public function run(): void
'name' => 'Diskon 10%',
'code' => 'DISC10',
'type' => VoucherType::PERCENTAGE,
+ 'tags' => 'DISC 10%',
+ 'summary' => 'Diskon 10% untuk pembelian minimal Rp50.000',
'discount_amount' => 10,
'min_purchase' => 50000,
'max_discount' => 20000,
@@ -29,6 +31,8 @@ public function run(): void
'name' => 'Diskon 20%',
'code' => 'DISC20',
'type' => VoucherType::PERCENTAGE,
+ 'tags' => 'DISC 20%',
+ 'summary' => 'Diskon 20% untuk pembelian minimal Rp100.000',
'discount_amount' => 20,
'min_purchase' => 100000,
'max_discount' => 50000,
@@ -40,8 +44,10 @@ public function run(): void
],
[
'name' => 'Potongan Rp25K',
- 'code' => 'SAVE25K',
+ 'code' => 'SAVE 25K',
'type' => VoucherType::FIXED,
+ 'tags' => 'SAVE 25K',
+ 'summary' => 'Potongan Rp25K untuk pembelian minimal Rp100.000',
'discount_amount' => 25000,
'min_purchase' => 100000,
'max_discount' => null,
@@ -55,6 +61,8 @@ public function run(): void
'name' => 'Potongan Rp50K',
'code' => 'SAVE50K',
'type' => VoucherType::FIXED,
+ 'tags' => 'SAVE 50K',
+ 'summary' => 'Potongan Rp50K untuk pembelian minimal Rp200.000',
'discount_amount' => 50000,
'min_purchase' => 200000,
'max_discount' => null,
@@ -68,6 +76,8 @@ public function run(): void
'name' => 'Gratis Ongkir',
'code' => 'ONGKIR',
'type' => VoucherType::FIXED,
+ 'tags' => 'GRATIS ONGKIR',
+ 'summary' => 'Gratis Ongkir untuk pembelian minimal Rp50.000',
'discount_amount' => 15000,
'min_purchase' => 50000,
'max_discount' => 15000,
@@ -81,6 +91,8 @@ public function run(): void
'name' => 'Flash Sale 30%',
'code' => 'FLASH30',
'type' => VoucherType::PERCENTAGE,
+ 'tags' => 'FLASH 30%',
+ 'summary' => 'Diskon 30% untuk pembelian minimal Rp75.000',
'discount_amount' => 30,
'min_purchase' => 75000,
'max_discount' => 40000,
@@ -94,11 +106,12 @@ public function run(): void
'name' => 'Spesial Member',
'code' => 'MEMBER15',
'type' => VoucherType::PERCENTAGE,
+ 'tags' => 'Serial Member',
+ 'summary' => 'Diskon 15% untuk pembelian minimal Rp50.000',
'discount_amount' => 15,
'min_purchase' => 50000,
'max_discount' => 25000,
'quota' => null,
- 'available_count' => null,
'limit_per_user' => null,
'start_date' => now(),
'end_date' => null,
diff --git a/resources/views/livewire/studio/loyalty/voucher/form.blade.php b/resources/views/livewire/studio/loyalty/voucher/form.blade.php
index 0c8cb13..2790ecb 100644
--- a/resources/views/livewire/studio/loyalty/voucher/form.blade.php
+++ b/resources/views/livewire/studio/loyalty/voucher/form.blade.php
@@ -32,9 +32,15 @@
oninput="this.value = this.value.toUpperCase()" />