From bd57eada370c27c40f9c8297eff1dcd60ecd4b31 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Mon, 8 Dec 2025 11:25:45 +0700 Subject: [PATCH] fic(voucher): convert string kosong ke null --- app/Livewire/Forms/Studio/Loyalty/VoucherForm.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php index 1ed668d..aa5b290 100644 --- a/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php +++ b/app/Livewire/Forms/Studio/Loyalty/VoucherForm.php @@ -125,6 +125,12 @@ public function store() $data = $this->prepareSavedData(); + foreach (['min_purchase', 'max_discount', 'quota', 'limit_per_user'] as $field) { + if ($this->$field === '') { + $this->$field = null; + } + } + DB::transaction(function () use ($data) { $voucher = Voucher::create($data); @@ -137,6 +143,7 @@ public function update() $this->validate(); $data = $this->prepareSavedData(); + DB::transaction(function () use ($data) { unset($data['available_count']); $this->voucher->update($data);