Level 75
Mar 25, 2017
3
Level 1
Level 122
@include is the same concept as a php include, get the named file and insert it at this point in the document.
@yield is more complicated but still quite simple.
When you load a view, eg 'home', at the start of the file it might declare that it extends a master layout.
At this point, control transfers to the master layout and the content from the master is output until you reach a @yield (like 'give way'). Now, control switches to a named section in the original view, until the end of the section, when it then reverts back to the master again
// Welcome blade Master blade
//
// extend master ------------------>
// content
// content
// content
// @yield ('body')
// <------------------------------
// @section 'body'
// content
// content
// content
// @end section
// ------------------------------>
// content
// content
// content
5 likes
Please or to participate in this conversation.