Where to put specific logic in CakePHP

I recently started rewriting a project that I did a few years ago using CakePHP. This time I'm trying to do everything right, so maybe someone will give me a pointer to the following:

I am showing a simple table from a table using Model-> find ('all') in the view. There are two Boolean fields in this table, which together make up what I need to show the user. So: 0x0 = 'A', 1x0 = 'B', 0x1 = 'C', 1x1 = 'D'. Where should I put this logic? I thought of the following methods:

  • View
  • View Assistant
  • Controller
  • Something in the model, so Model-> find ('all') prints this value (is this possible?)

This task may seem trivial, but I think that it can teach me that this project should be organized and supported from the very beginning.

Thank!

+3
source share
4 answers

Well, it depends on the type of logic for compiling the final table (is it a presentation or a business?).

, , . ? , View, HTML, . , , , - -, . , , (, , ).

.

+5

, , . , afterFind .

+1

, , . , .

, datamodelling, . !

0

! . (, HTML UI).

-1

Source: https://habr.com/ru/post/1733144/


All Articles