M
M
Maxim Volkov2021-10-15 12:48:25
Software design
Maxim Volkov, 2021-10-15 12:48:25

How to modify correctly: calculate and add to the data received from the model?

It is necessary to display goods at a discount. Data for products and given discounts is stored in different tables: 'products' and 'discounts' are many-to-many related.

When displaying a list of goods and a detailed page of goods, it is necessary to obtain modified data of goods already calculated based on the parameter of the base price of the goods and the discount - data located in different tables:

• discount percentage, old and new price, benefit - the difference between the old and new prices etc.
• that discounted products received from the model already contain the specified data in the form of a collection or array.

I don't think this should be done in a controller. What is the best approach to take? Where to look?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2021-10-15
@voland700

Look in the direction of "make a service that will accept data as input, process it and return it."

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question