php - Shared sections in master layout containing db data -


in laravel 5.1 app, have master layout shared section, let's sidebar list of 5 recent site posts. section content dynamic (elaborated db query), identical on every website page.

to obtain this, in master layout @include sub-view containing sidebar code, still mean repeating same db query in each controller action, lot of code repetition. i'm sure there smarter way obtain this, couldn't figure out. appreciated.

as can see here under sub views can pass data include such as

@include('view.name', ['some' => 'data']) 

then need pass data master layout.

edit: view composers looking seems


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -