When developing an application with Laravel, I came across a question about the proper place (or indicated by the best practices) to put methods to format data.
As an example, I have a model Rubrica
with fields fonte
, despesa
, etc.
The despesa
field stores a 6-character string and the fonte
field stores a 5-character string.
It turns out that for viewing on views, I wish you despesa
is in a.b.cd.ee format and fonte
is in ABC.de format.
The doubt I have is, the correct thing is to call formatting functions, for example fmt_despesa()
and fmt_fonte ()
directly on the view (in this case, the functions would be defined as Helpers in /App/support/helper.php
);
Or should create the static methods needed in the controller (RubricaController
) by calling them directly on the view;
Or, you should put the formatting methods on the Rubrica
model and call directly on the view in each recovered register of the model.
I really didn’t find it in the documentation of the Laravel guidelines in this regard. I also found nothing relevant on the internet, including the OS.
I am grateful for the help and eventual feedback if the question is not properly written.