online software programming courses

Difference between yield and include laravel

The differences between @yield and @include in laravel

difference between yield and include in laravel

 

 

 

 

 

 

1. @yield is used in main template or master layout

2. @include is used for showing static content in master layout, like if you want to include header.blade.php and footer.blade.php in master template then you will use @include(header) and @include(footer) in your master template

3. @yield goes into the body section of your master template.

<body>
     @yield('content_id')
</body>

of course, if you want to use yield directive in your master template, you will have to use @section directive in your partials. Master template get dynamic data from partials and show in the browser. In your partials you will use the section directive like below

@section('content_id')
      My content for a certain page. I will include lots of content for SEO...
@endsection