feat(discount): memberikan kondisi voucher hanya berlaku di outlet tersebut

This commit is contained in:
Yoga Pangestu 2025-11-10 22:59:39 +07:00
parent 2688b86a4d
commit 89fffb2cb1

View File

@ -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