Level 1
Promotion::where('product_id',$product) ->whereRaw('('.$quantity.'%promotion_quantity) = 0') ->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
When user buy two of the item will get a discount. Now the problem is when the user buy four qty of the product i cant match it out. Therefore i need to do some math in query. Like quantity%database.quantity == 0.
How can i do that in my query
$promotionID = Promotion::where('product_id',$product)
->whereRaw('promotion_quantity%'.$quantity.'=0')
->get();
Promotion::where('product_id',$product) ->whereRaw('('.$quantity.'%promotion_quantity) = 0') ->get();
Please or to participate in this conversation.