1

This is a general question and I'm asking for design patterns, approach, or what terms to even properly search for to determine the best approach. More specifically, I am working on a project in Laravel 4.2, with standard blade file views with a master.blade.php, a header, footer etc.., and they just get built with the View::make('location.of.template', ..) method, passing the parameters as needed.

The views have very little "logic" in them and just present the collection of data provided. I somewhere recall that a model should not know what a view does with the data provided, it was up to the view to manage this presentation.

But what is the rule for using calls to methods inside the view? This seems extremely useful to me and gives the view authority to call an HTML string based on a single element's $id, and relieves the view of having to prepare every possible scenario for the view's sake. This seems very useful for a page that is 100% server-side, and even better if the methods the view would call are also available as APIs using AJAX secondary calls. Is there a generally accepted guideline on when and what type of methods to use in views?

Oliver Williams
  • 5,966
  • 7
  • 36
  • 78
  • 1
    Yes, well as much as I wanted, I couldn't understand your last phrase (I'm kind of tired right now). But, I intuit what you're asking. Therefore, I'll recommend you to begin with [THIS](https://stackoverflow.com/questions/16594907/understanding-mvc-views-in-php/16596704#16596704) and [THIS - Part 1 + Part 2](https://r.je/views-are-not-templates.html). Then [THIS](https://stackoverflow.com/questions/5863870/how-should-a-model-be-structured-in-mvc/5864000#5864000). –  Jun 02 '17 at 08:22
  • 1
    I also wrote an [answer to my own question](https://stackoverflow.com/questions/43827868/mvc-too-many-dependencies-in-controller/44032752#44032752) some time ago, maybe it is of some interest for you. Skip the first part with dependencies. The answer is just a completion and a description in my own words of the great content from the 2nd link above. Good luck. –  Jun 02 '17 at 08:29
  • All of these links are very relevant and helpful answers to my question, thanks. – Oliver Williams Jun 04 '17 at 00:41
  • You are welcome! I hoped so. They are the most relevant ones on the web regarding of what you've asked and what you want to achieve, imho. Their authors have an in-depth knowledge and experience of all these parts making a good MVC sytem. Good luck. –  Jun 04 '17 at 00:51

0 Answers0