Reputation: 117
I'm using two @yield on one page for the main content and the second for navbar, but navbar is not showing at all, I'm new to laravel and must have learned some concept the wrong way. The project follows the following folder structure
views /
component / navbar.blade.php
layouts / main.blade.php
reviewer / reviewer.blade.php
web.php
Route::resource('reviewer', 'ReviewerController');
ReviewerController.php
public function index(){
$title = "All Project";
$projects = session('projects');
return view('reviewer.index', compact(['projects','title']));
}
main.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace(' _', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@yield('navbar')
@yield('conteudo')
</body>
</html>
reviewer.blade.php
@extends('layouts.main')
@section('conteudo')
<h3> {{$title}} <h3>
<ul>
@foreach( $projects as $p )
<li> {{ $p['id'] }} | {{ $p['name'] }} | {{ $p['appraiser']}} | {{ $p['student'] }} </li>
@endforeach
</ul>
@endsection
navbar.blade.php
@extends('layouts.main')
@section('navbar')
<div id='menu'>
<ul>
<li><a href="#">Início</a></li>
<li><a href="#">Edital</a></li>
<li><a href="#">Resultados</a></li>
<li><a href="#">Bem vindo user</a></li>
</ul>
</div>
@endsection
Upvotes: 0
Views: 326
Reputation: 3702
Try this your main.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace(' _', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
@include(' component.navbar')
@yield('conteudo')
</body>
</html>
reviewer.blade.php
@extends('layouts.main')
@section('conteudo')
<h3> {{$title}} <h3>
<ul>
@foreach( $projects as $p )
<li> {{ $p['id'] }} | {{ $p['name'] }} | {{ $p['appraiser']}} | {{ $p['student'] }} </li>
@endforeach
</ul>
@endsection
navbar.blade.php
<div id='menu'>
<ul>
<li><a href="#">Início</a></li>
<li><a href="#">Edital</a></li>
<li><a href="#">Resultados</a></li>
<li><a href="#">Bem vindo user</a></li>
</ul>
</div>
ReviewController.php
public function index(){
$title = "All Project";
$projects = session('projects');
return view('reviewer.reviewer', compact(['projects','title']));
}
Upvotes: 1