Reputation: 17
I am developing a forum in php oop in mvc , but I got a question this is my structure, so where do I must write the set and get methods of each model?, I begin to put the clasess setgetThread, and setgetReply in the controller but I dont sure, can you give some hints, or clarify me if I am doing a goo practice??, I am new in mvc, and I am trying to understand
Controller: ControllerThread, ControllerReply
Model: Thread, Reply
View: Formthread, FormReply, Index
Upvotes: 0
Views: 556
Reputation: 29874
This question cant be answered exactly.
It depends on style and convention.
Best practices I know is to "keep your controller as skinny as possible" and have a "fat model" instead.
The Model should contain business logic and should be fully operational, but on an environment independent state. Which means for example, dont process HTML there. Just exchange defined data objects.
The controller is responsible to map all the urls to the right place and everything.
Finally the view transforms the data from the model into a form that the user can view (e.g. HTML).
Sometimes it is convention to exchange only data between view/controller or model/controller. I personally see no reason why not to let the model interact with the controller, it brings big advantages like pre processing of data etc.
So to drill it down to your question:
I think your controller should load the model and set the thread.
Then then controller should set the correct view in your presentation layer, which then fetches the posts from the model and dispalys them in a nice form.
Upvotes: 1