Please tell me how it would be correct to set global variables or variables for the main template. Those. I have here such a tree of templates main.blade index.blade (in which I inherit main.blade), etc. How can I transfer variables with site-title and others to the main template (of course, you can make bones, but I would like to know how this is done correctly)
2 answers
Everything is perfectly described in the documentation .
- Using facades
View::share('key', 'value') - Using helper
view()->share('key', 'value')
|
In main.blade in the right place, insert
@yield('title') In index.blade insert
@section('title', 'Page Title') Documentation: https://laravel.com/docs/5.2/blade#defining-a-layout
|