L
L
l4m3r2018-10-06 12:31:18
Software design
l4m3r, 2018-10-06 12:31:18

Do you need a layer between controller and view?

I don't have much experience. I often notice that after receiving the data in the controller, and before putting it into the view, you need to prepare certain transformations for this view. Well, for example:

  • We got a flat list of models and bases, and we display a tree structure. Where to write code that converts from a plane to a nested array for convenience of output?
  • I am exporting data to excel. Writing a 500-line action with PhpExcel's footcloth is somehow not comme il faut. Where to shove it?
  • You need to prepare auxiliary data for drop-down lists that are not directly related to the current action (for example, the list of cities and countries in the user edit). Where can I download them? In action?
  • Often the view contains patterns. For example, filters on top (select, input, ...), filtered table below. However, it should be customizable. Is there some architectural solution to not copy on every entity. For example, I set the config of filters and tables, and then there is an output to the blade. Where should this code and config be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-10-06
@JhaoDa

1.a. Get a tree structure from the database immediately, after saving it there. Google Nested set, ajacency list, etc.
1.b. Use presenters.
1.c. Use service layer.
2.a. Use presenters.
2.b. Use service layer.
3. Use view composer/view creator.
4. In the config. And, perhaps, see point 3.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question