You need to understand how blade template inheritance work. Take some time, and read this awesome documentation!
Here is a good explanation:
├─── main.blade.php [Parent layout, with @yield]
│
│ └─── section.blade.php [This is the children, with @section]
│ └─── otherfile.blade.php [This is another children, @section]
Remember, when using @yield, it always return empty if you access the file directly as view. It is special made for children. Just like you give a baby formulated milk, you don't drink it, your baby does! Thus, access it ONLY with children when using @yield and @section
In your router, you have to set the view as
public function section(){
return view('section.blade.php');
}
If you want to view the parent instead, and include the children inside it, feel free to use @include
tag as follow in your parent template file.
@include('section')
├─── main.blade.php [Parent layout, with @include('section')]
│
│ └─── section.blade.php [This is the children to be included]
│ └─── otherfile.blade.php [This is another children]
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community