fix(voucher): set value untuk tags. menghapus fungsi sanitizeIntegers() dan unset available_count saat update
This commit is contained in:
parent
1b14ce5ffb
commit
b2069964f5
@ -105,7 +105,7 @@ public function setVoucher(Voucher $voucher)
|
|||||||
|
|
||||||
$this->name = $this->voucher->name;
|
$this->name = $this->voucher->name;
|
||||||
$this->code = $this->voucher->code;
|
$this->code = $this->voucher->code;
|
||||||
$this->summary = $this->voucher->summary;
|
$this->tags = $this->voucher->tags;
|
||||||
$this->type = $this->voucher->type->value;
|
$this->type = $this->voucher->type->value;
|
||||||
$this->discount_amount = replaceCurrency($this->voucher->discount_amount);
|
$this->discount_amount = replaceCurrency($this->voucher->discount_amount);
|
||||||
$this->min_purchase = replaceCurrency($this->voucher->min_purchase);
|
$this->min_purchase = replaceCurrency($this->voucher->min_purchase);
|
||||||
@ -124,7 +124,6 @@ public function store()
|
|||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
$data = $this->prepareSavedData();
|
$data = $this->prepareSavedData();
|
||||||
$data = sanitizeIntegers($data, ['min_purchase', 'max_discount', 'quota', 'limit_per_user', 'available_count']);
|
|
||||||
|
|
||||||
DB::transaction(function () use ($data) {
|
DB::transaction(function () use ($data) {
|
||||||
$voucher = Voucher::create($data);
|
$voucher = Voucher::create($data);
|
||||||
@ -139,6 +138,7 @@ public function update()
|
|||||||
|
|
||||||
$data = $this->prepareSavedData();
|
$data = $this->prepareSavedData();
|
||||||
DB::transaction(function () use ($data) {
|
DB::transaction(function () use ($data) {
|
||||||
|
unset($data['available_count']);
|
||||||
$this->voucher->update($data);
|
$this->voucher->update($data);
|
||||||
|
|
||||||
$this->voucher->outlets()->sync($this->outlet_ids);
|
$this->voucher->outlets()->sync($this->outlet_ids);
|
||||||
@ -156,7 +156,7 @@ private function prepareSavedData()
|
|||||||
'min_purchase' => replaceCurrency($this->min_purchase),
|
'min_purchase' => replaceCurrency($this->min_purchase),
|
||||||
'max_discount' => $this->type == VoucherType::PERCENTAGE->value ? replaceCurrency($this->max_discount) : null,
|
'max_discount' => $this->type == VoucherType::PERCENTAGE->value ? replaceCurrency($this->max_discount) : null,
|
||||||
'quota' => $this->quota,
|
'quota' => $this->quota,
|
||||||
'available_count' => $this->quota,
|
'available_count' => $this->quota ?? 0,
|
||||||
'limit_per_user' => $this->limit_per_user,
|
'limit_per_user' => $this->limit_per_user,
|
||||||
'summary' => $this->summary,
|
'summary' => $this->summary,
|
||||||
'start_date' => $this->start_date,
|
'start_date' => $this->start_date,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user