diff --git a/app/Traits/Order/WithMember.php b/app/Traits/Order/WithMember.php index 27f4fec..e5f49a6 100644 --- a/app/Traits/Order/WithMember.php +++ b/app/Traits/Order/WithMember.php @@ -38,20 +38,15 @@ public function updatedFormMemberId(?string $member_id = null) } $memberId = $customer->user?->id; + $outletId = $this->form->outlet_id; $this->vouchers = Voucher::whereHas('users', function ($q) use ($memberId) { $q->where('user_id', $memberId); }) - ->where(function ($q) { - $q->where(function ($q) { - $q->whereNull('start_date') - ->orWhere('start_date', '<=', now()); - }); - $q->where(function ($q) { - $q->whereNull('end_date') - ->orWhere('end_date', '>=', now()); - }); + ->whereHas('outlets', function ($q) use ($outletId) { + $q->where('outlet_id', $outletId); }) + ->active() ->select('id', 'name', 'type', 'discount_amount', 'max_discount') ->orderByRaw(" CASE