feat(discount): memberikan kondisi voucher hanya berlaku di outlet tersebut
This commit is contained in:
parent
2688b86a4d
commit
89fffb2cb1
@ -38,20 +38,15 @@ public function updatedFormMemberId(?string $member_id = null)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$memberId = $customer->user?->id;
|
$memberId = $customer->user?->id;
|
||||||
|
$outletId = $this->form->outlet_id;
|
||||||
|
|
||||||
$this->vouchers = Voucher::whereHas('users', function ($q) use ($memberId) {
|
$this->vouchers = Voucher::whereHas('users', function ($q) use ($memberId) {
|
||||||
$q->where('user_id', $memberId);
|
$q->where('user_id', $memberId);
|
||||||
})
|
})
|
||||||
->where(function ($q) {
|
->whereHas('outlets', function ($q) use ($outletId) {
|
||||||
$q->where(function ($q) {
|
$q->where('outlet_id', $outletId);
|
||||||
$q->whereNull('start_date')
|
|
||||||
->orWhere('start_date', '<=', now());
|
|
||||||
});
|
|
||||||
$q->where(function ($q) {
|
|
||||||
$q->whereNull('end_date')
|
|
||||||
->orWhere('end_date', '>=', now());
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
|
->active()
|
||||||
->select('id', 'name', 'type', 'discount_amount', 'max_discount')
|
->select('id', 'name', 'type', 'discount_amount', 'max_discount')
|
||||||
->orderByRaw("
|
->orderByRaw("
|
||||||
CASE
|
CASE
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user