D
D
darksladen2018-06-15 23:11:33
Software design
darksladen, 2018-06-15 23:11:33

How to group logic and is it worth it?

Tell me, how best to group the logic? For example, you need to make a purchase of a product. I would like to do it something like this
$product->buy($userId);
. That is, in this method, a discount should be calculated, some status should be assigned to the product, it is possible for the user to withdraw money from the account, etc. As I understand it, you need to make a service and a trait for the model that can do this work and in which the main logic will be written, but it is not clear how to connect it with the models and my application, it turns out a bunch of dependencies. That is, he must use some kind of discount module, a module of promotional codes, for example .. I don’t understand how to connect all this, please explain!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question