I'm having troubles with Blade showing a section. This is my main layout file:
<!DOCTYPE html>
<html lang="en">
<!-- Include Header -->
@include('layouts.header')
<body class="index-page">
<!-- Include Navigation -->
@include('layouts.navigation')
<div class="wrapper">
@include('layouts.banner')
<div class="main main-raised">
<!-- Include Content -->
@yield('content')
</div>
</div>
<!-- Include Footer -->
@include('layouts.footer')
<!-- Include Modals -->
@include('layouts.modals')
<!-- Include Scripts -->
@include('layouts.scripts')
</body>
</html>
And this is the layouts.header file:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Title</title>
<!-- Styles -->
<link href="/assets/css/app.css" rel="stylesheet">
@yield('styles')
<!-- Fonts -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
<!-- Scripts -->
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
@yield('header')
</head>
And finally, the navigation file:
@if (Auth::user())
@section('styles')
<link href="/assets/css/vendor/wizard.css" rel="stylesheet">
<link href="/assets/css/vendor/bootstrap-select.css" rel="stylesheet">
<link href="/assets/css/vendor/summernote.css" rel="stylesheet">
@endsection
@endif
<nav class="navbar navbar-fixed-top navbar-color-on-scroll navbar-
<!-- A lot of boring code here -->
</nav>
@section('modals')
@if (Auth::user())
@include('layouts.modals.addonupload')
@else
@include('layouts.modals.login')
@include('layouts.modals.register')
@include('layouts.modals.reset')
@endif
@endsection
@section('scripts')
@if (Auth::user())
@include('layouts.modals.js.addonupload')
@endif
@endsection
So, in theory, the css files I define in layouts.navigation on the top should get included in the header where I yield them. But they don't for some reason.
Mind you, the modals I include at the bottom of the navigation work as intended. Further more, I had this working before. But I had the css section (which is now in the navigation file) in another view responsible for the content. All I did was to move the styles section from the content view file into the navigation file.
The background is this: I have a modal that requires certain css and js files. I want to provide that modal on every view as long as the user is logged in. I don't want to hard code them into the header because I don't need them if the user is not logged in. And again, the modals and scripts section at the bottom work fine. Just the styles section doesn't get included in the header. Would anyone know why?
Thanks!