In my Laravel 5.1 app, I have a master layout with a shared section, let's say a sidebar with a list of the 5 most recent site posts. The section content is dynamic (elaborated from a db query), but identical on every website page.
To obtain this, in the master layout I could @include a sub-view containing the sidebar code, but that would still mean repeating the same db query in each controller action, which is a lot of code repetition. I'm sure there is a smarter way to obtain this, but I couldn't figure it out. Any help would be really appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire