Calling Function in View - Laravel 5.5

Asked

Viewed 337 times

0

Guys, it’s been a while since I programmed PHP and I have the following question:

I am calling a function in my View as follows:

{{ $result_resumo = app(App\Http\Controllers\Site\SiteController::class)->NoticiasResumo($dados_noticias->post,80, FALSE, "") }}

Now I ask:

There is another way to call the function without the need to type the whole path of the Controller?

Note: I am using Laravel Framework 5.5

  • Next, it does not need to be so, what does the method do? It is not good to instantiate a controller that way. I wonder what you want to do? put all the dots.

  • this method formats the text so I display a formatted news summary, it removes html tags, etc etc ... I’m calling it that way.... How best to call this method in the view?

  • 1

    Make a helper (or function, function) or even a package of utilities and call the code in your controller sending to view only the result. You can’t commit Controller directly on View.

  • This goes kind of against the concept of MVC not? How about sending the formatted data when calling the view in the controller? So I would only have the job of printing the variable passed to Lade...(as Virgilio said)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.