default MVC for Controller in codeigniter

0

I have the following scenario, some models that will be accessed via administration (site) and via client (app), in administration it can read and write data and in the client only read data.

My question, what is the best way to follow the MVC pattern to optimize code (do not repeat)?

Since the administration and client will consume data, being the only difference that one will consume in html and the other json.

I thought of making a controller containing all the communication with the models and one more controller for each purpose (administration and model), they would access the main controller.

Is this my thinking correct?

    
asked by anonymous 21.03.2017 / 01:00

1 answer

1

Danilo, I advise you to add an intermediate layer to receive the business rules. It would be between Controller and Model , this layer is usually called a Service . Well, the replication of the code can be up to zero. In addition to a Controller for each communication path. For one power to render the screen is the other returns json format or any other.

    
21.03.2017 / 09:27