If I'm understanding this correctly, push is adding to a stack that can be rendered in a parent view. default.blade has no parent view so you can't push there.
Blade Stacks - Pushing into an included view
I recently picked up Laravel and so far I love the feature-rich simplistic nature of the framework. What I certainly love is the Stacks feature Blade offers, but I'm seeing a headache I cannot overcome.
I have a file, default.blade.php that defines a standard HTML document structure. Within the
I @include('layouts/global/head'). This file, by definition, includes anything that may exist in the section, including any style sheets. It is here where I too defined @stack('styles-head')Looking back at the default.blade.php file then, directly underneath the @include('layouts/global/head') statement exists @push('styles-head') ... @endpush. The issue however, and I presume it is because the file is included and not native, is that the push does not append to the stack.
On the other hand, throwing this push in a file, features.blade.php, that is used to purely serve the content, works. This file differs in that it extends, but it extends default.blade.php - the same file I tried adding the push to directly.
Any idea what gives? I am at a complete loss.
--
default.blade.php
<!DOCTYPE html>
<html>
<head>
@include('layouts/global/head')
@push('styles-head')
// stylesheet associated to front-facing pages
@endpush
</head>
<body>
<div class="contents">
@yield('content')
</div>
</body>
</html>
head.blade.php
<title>Test</title>
<link href="a global style-sheet">
@stack('styles-head')
features.blade.php
@extends('.../default')
@section('content')
<h1>Hello world</h1>
@endsection
Please or to participate in this conversation.