Tuesday, February 28, 2017

Is it possible to retrieve database records inside a Blade View (Laravel)?

I know database work shouldn't be done inside the view, but unless there's another way, I think I need to do it.

In my web application, I use the same sidebar for every web page and I want to display records from a table in the sidebar. I don't want to have to retrieve those records in EVERY controller method in my application (as there is a lot).

Is it possible to do this inside a blade view? Or is there another way I should do it?




via Alex Naughton

Advertisement