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);