From e799de83e55c273b4f5d32f7d8e22b30d33d4198 Mon Sep 17 00:00:00 2001 From: Aji Kamaludin Date: Sun, 25 Jun 2023 21:16:17 +0700 Subject: [PATCH] bugfix same code on process cart --- app/Http/Controllers/Customer/CartController.php | 4 +++- app/Models/Voucher.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Customer/CartController.php b/app/Http/Controllers/Customer/CartController.php index 4f65b1d..b27e435 100644 --- a/app/Http/Controllers/Customer/CartController.php +++ b/app/Http/Controllers/Customer/CartController.php @@ -142,7 +142,9 @@ class CartController extends Controller 'entity_id' => $voucher->id, 'price' => $voucher->validate_price, 'quantity' => 1, - 'additional_info_json' => json_encode($item), + 'additional_info_json' => json_encode([ + 'voucher' => $voucher->load(['locationProfile.location']) + ]), ]); $voucher->update(['is_sold' => Voucher::SOLD]); diff --git a/app/Models/Voucher.php b/app/Models/Voucher.php index 4b5bbaa..ca870d3 100644 --- a/app/Models/Voucher.php +++ b/app/Models/Voucher.php @@ -143,12 +143,12 @@ class Voucher extends Model ['location_profile_id', '=', $this->location_profile_id], ])->count(); - $treshold = $this->location_profile->min_stock; + $treshold = $this->locationProfile->min_stock; if ($count <= $treshold) { Notification::create([ 'entity_type' => User::class, - 'description' => 'stok voucher ' . $this->location_profile->name . 'tersisa : ' . $count, + 'description' => 'stok voucher ' . $this->locationProfile->name . 'tersisa : ' . $count, ]); } }