1

I want to discuss some details about implementing the MVC pattern in laravel. Actually I think about one issue. The role of a controller.

I have noticed that many developers write a controller code as follows : they get some data from a request, pass this data to a model, get processed data from a model and send it back to a view. In short - controller queries the model and passes the result to the view.

I found an interesting article about MVC pattern. https://r.je/views-are-not-templates

According to the article above, such controler implementation is wrong. The author gives many convincing arguments. What do you think about it? Should we access models directly in a view?

Shaunak Sontakke
  • 980
  • 1
  • 7
  • 17
Artek
  • 57
  • 7
  • Only, in your description, it is not a "model" but a table-abstraction, not a "view" but a template and .. well .. I think you might be already figuring out that it is not actually a "controller" :D Also, I wrote few [answers](https://stackoverflow.com/a/5864000/727208) regarding that some years ago, might be useful. – tereško Sep 20 '19 at 20:13
  • Nice answer shared by you, gonna read by myself. – Dark Knight Sep 20 '19 at 20:18
  • Let me get this straight. The controller class in laravel is not a controller in mvc? – Artek Sep 20 '19 at 20:34
  • At best is a merger of view and controller responsibilities. Usually with service layer being merged into it too. – tereško Sep 20 '19 at 20:43

0 Answers0