jeudi 28 janvier 2016

Shared sections in master layout containing db data

my first post here, so be patient. I tried looking for an answer before posting but no luck.

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, wich 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.

Thanks in advance and please be patient, I'n new to Laravel (and to stack overflow).



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire