How can I create dynamic min and max validation for specific item?
For buying I am using model Buy, and for products I am using model Products. I need to implement this rules in the Buy model.
Example - I am looking item with id 12, and this item have stock of 100 units (this needs to be maximum) and minimum order of 10 (this needs to be minimum).
EDIT:
Products (item) table:
id
name
stock
minOffer
Buy table:
id
offer
product_id
user_id
Offer for buying can't be larger then current stock in the product table.