Laravel - Send Variable to layout master and keep it during session

人走茶凉 提交于 2019-12-04 18:54:14

Laravel has a nice way to handle issues where a same data is used in all views. View Composer is what you are looking for.

View::composer(array('view1','view2'), function($view)
{
    $view->with('data', 'value');
});

Now data varaible is bound to view1 and view2. That means they it will be available every time you load these views.

Where to place them? You can place your view composers wherever you want as long as Laravel can identify it.

Read docs: View Composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!