Answer the question
In order to leave comments, you need to log in
Theoretical question about correct code. How to correctly implement a method ("not action") in the controller within the framework of MVC?
The controller has a method that implements a lot of functionality used in the actions of this controller. (data exchange between some arbitrary models).
This functionality does not logically fit into any specific model.
Logically (in my opinion) it is part of the controller.
Is it right to leave this code in the controller or is it better to take it out somewhere?
The essence of torment:
On the one hand, it seems to be in its place, but on the other hand, it occupies most of the controller, and in principle, is it better that the controller contains only methods (actions) accessible from outside?
Answer the question
In order to leave comments, you need to log in
Create a service and put "data exchange between some arbitrary models" there.
Name it so that it is clear what kind of exchange is taking place and use it in the controller.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question