First, with @extends('layouts.master'), we define that this view should not be rendered on its own, but that it instead extends another view. That means its role is to define the content of various sections, but not to stand alone. It’s almost more like a series of buckets of content, rather than an HTML page. It also defines that the view it’s extending lives at resources/views/layouts/master.blade.php.

@section and @endsection

Second, with @section('title', 'Dashboard'), we provide our content for the first section, title. Since the content is so short, instead of using @section and @endsection, we’re just using a shortcut. This allows us to pass the content in as the second parameter of @section and then move on. If it’s a bit disconcerting to see @section without @endsection, you could just use the normal syntax.

Third, with @section('content') and on, we use the normal syntax to define the contents of the content section. We’ll just throw a little greeting in for now. Note, however, that when you’re using @section in a child view, you end it with @endsection (or its alias @stop), instead of @show, which is reserved for defining sections in parent views.


Fourth, with @section('footerScripts') and on, we use the normal syntax to define the contents of the footerScripts section.

But remember, we actually defined that content (or, at least, its “default”) already in the master layout. So this time, we have two options: we can either overwrite the content from the parent view, or we can add to it.

You can see that we have the option to include the content from the parent by using the @parent directive within the section. If we didn’t, the content of this section would entirely overwrite anything defined in the parent for this section.


So, we have the basics of inheritance established. There are a few more tricks we can perform.

What if we’re in a view and want to pull in another view? Maybe we have a call-to-action “Sign up” button that we want to re-use around the site. And maybe we want to customize its button text every time we use it. Take a look below

Including view partials with @include
<!-- resources/views/home.blade.php --> <div class="content" data-page-name="{{ $pageName }}"> <p>Here's why you should sign up for our service: <strong>It's Great.</strong></p> @include('sign-up-button', ['text' => 'See just how great it is']) </div> <!-- resources/views/sign-up-button.blade.php --> <a class="button button--callout" data-page-name="{{ $pageName }}"> <i class="exclamation-icon"></i> {{ $text }} </a>

@include pulls in the partial and, optionally, passes data into it. Note that, not only can you explicitly pass data via the second parameter of @include, you can also reference any variables that are available to the including view ($pageName, in this example). Once again, you can do whatever you want, but I would recommend you consider always passing every variable explicitly that you intend to use, just for clarity.

Chapter 2 of 4