Hello people, I wanted to know if there is any technical difference, in principle and for the function that I give them, they would be working the same.
It seems clearer to use @include
. but I would like to know if there is any detail that I should know so as not to abuse it.
What I see as a difference is how it is implemented in the code, for example.
If you have a
@include
like to implement in PHP is that it is only for a specific code that you call from another site, instead@yield
you put a "name" to put it in some way. That is,@yield('contenido')
and that content can be displayed from other views that are referenced to that@yield
.Obviously in code you make the extension to where that
yield
.That's how I see it. The one
@yield
for many calls and the@include
one for a specific one.@yield
it will look for a section established in the current page (or view) and it will show it in that place, it can also add a default value in case there is nothing in said section.This
@yield('titulo', 'Mi sitio')
will include whatever is defined in@section Blog @endsection
a view (the Blog text in this case), if nothing is defined, it will display the My Site text.The source code for @yield is:
@include
it will simply include another view in the current one, in such a way that it@include('blog.articulo')
will search for the fileviews\blog\articulo.blade.php
and include it in the current view, all its content.The source code for @include is: