I've got a model for product, and a model for a sale - the product has a price, and the sale has start and end dates, and a modifier (e.g. reduce by 10%)
I can $appends a sale_price to my Product model that will pick up if the current product is in a sale. What I would prefer to do is overwrite the Product's price attribute with the calculated sale price if we know we're in a sale. So instead of, for example:
{
"price": "14.99",
"sale_price": "13.49"
}
I want the sale_price to override the product price so we just have:
{
"price": "13.49"
}
Is this possible?
Define a custom getter for price:
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community