C
C
chelkaz2017-05-31 17:51:31
Laravel
chelkaz, 2017-05-31 17:51:31

Functions in a view or better in a controller?

The project is growing and it turns out a lot of logic in the views.
So I think, can it be right to do all this in the controller, and pass the finished variable to the view ?
And now in the views there is a lot of such a plan:

{{ mb_ucfirst($locations->name).' - '.get_short_title($locations).env('STE_NAME') }}

That is, if it is better to prepare the final variables in the controller? And pass the ready-made $title to the template, which should be done in the controller:
$title = mb_ucfirst($locations->name).' - '.get_short_title($locations).env('STE_NAME');

And I have a lot of such functions for processing variables.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pantagruel964, 2017-05-31
@chelkaz

My eyes...
Anywhere but in a template. There are also assessors and mutators..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question