Laravel @stack Directive

The @stack directive allows you to create a field with the specified name. Thus, you can add page-specific content to this field in your other views using the @push directive.

For example, you can show page-specific js, css or some other code only when you enter that page.

In your layout page, in this example mine is layouts/index.blade.php, I created a field called custom-head inside my <head> tag.

// layouts/index.blade.php
<!doctype html>
    <meta charset="utf-8">
    <title>{{ config('', 'Laravel') }}</title>

And now, if I want to add a custom css, js or any code to that page in my subviews, we can use the @push directive.

// users.blade.php

    <link href="{{ mix('css/users.css') }}">

Unlike the @section and @yield directives, you can add content multiple times with these directives. However, the @section and @yield directives add one-time content.
And in addition, remember that you have to specify the page to extend with the @extends directive.


There are no comments, make the firs comment