Reputation: 25
I am trying to seperate my menu from the app.blade.php
. Why is the following not working?
views/layouts/app.blade.php
:
<body>
@yield('menu')
<div class="container">
@yield('content')
</div>
</body>
views/layouts/menu.blade.php
:
@extends('layouts.app')
@section('menu')
// Menu is here
@endsection
Upvotes: 0
Views: 1152
Reputation: 3419
You don't have to yield
the menu section but include
it. As you can read from the official documentation:
Blade's @include directive allows you to include a Blade view from within another view. All variables that are available to the parent view will be made available to the included view:
<div>
@include('shared.errors')
<form>
<!-- Form Contents -->
</form>
</div>
So your layouts/app.blade.php
file should look like this:
<body>
@include('layouts.menu')
<div class="container">
@yield('content')
</div>
</body>
Upvotes: 3
Reputation: 1373
Your app.blade.php should be look like this
locate : views/layouts/app.blade.php
<body>
@include('layouts.menu')
<div class="container">
@yield('content')
</div>
</body>
and your menu.blade.php
locate : views/layouts/menu.blade.php
// Menu's here
Upvotes: 2