i started learning laravel, , want include second controller main layout.
the route default root directory: /
and layout looks this:
<div class="container"> @yield('content') </div> <div class="basket"> ~basket comes here~ </div>
i want show user's basket, need db queries that, , can't find way include other controller, atleast not routing.
i'm not asking code (sadly didn't find better place question), need designing tip, feel i'm trying wrong, since couldn't find relevant/helpful information this.
and dont want put basket every controller uses main
layout.
any kind of apreciated, i'm lost :)
you should use view composers. open appserviceprovider , inside boot() method add following:
view()->composer('your.layout.name', function ($view) { $basket = ...// basket query here $view->with('basket', basket); });
this says, when view name your.layout.name composed, add variable name $basket.
Comments
Post a Comment