In general, there is a posts.blade.php view:

{{-- ПОСТЫ --}} @if(isset($posts)) @foreach($posts as $post) @include(env('THEME').'.content.post-preview',compact('post')) @endforeach @endif {{-- ПАГИНАЦИЯ --}} {{$posts->links()}} 

In a loop, a view is called to display the @include(env('THEME').'.content.post-preview',compact('post')) post @include(env('THEME').'.content.post-preview',compact('post')) to which the new value of $post is transmitted continuously.

Content post-preview.blade.php:

 @extends(env('THEME').'.content.layouts.post') @section('title') <a href="{{route('showPost',['alias'=>$post->alias])}}" class="mt-4 post_title post_link_title">{{$post->title}}</a> @endsection @section('body') <p class="card-text">{{$post->description}}</p> <a href="{{route('showPost',['alias'=>$post->alias])}}" class="btn btn-outline-info">Читать дальше &rarr;</a> @endsection @section('footer') <hr> <span class="text-muted"> <span class=""><i class="mr-2 ml-2 far fa-eye"></i>{{$post->views}}<a class="float-right comment_link " href="{{ route('showPost',['alias'=>$post->alias]) }}#disqus_thread"><i class="far mr-2 fa-comment-alt"></i>{{$post->getCommentsCount()}}</a></span> </span> <hr> @endsection 

post-preview extends the layout of post.blade.php:

 <!-- Автор, дата публикации --> @include(env('THEME').'.content.post.header') @yield('title') <!-- Tags --> @include(env('THEME').'.content.post.tags') <img class="card-img-top" src="{{$post->img}}" alt=""> <div class="card-body p-0"> @yield('body') </div> @yield('footer') 

As a result, corresponds to the content for each post:

 @include(env('THEME').'.content.post.header') @include(env('THEME').'.content.post.tags') <img class="card-img-top" src="{{$post->img}}" alt=""> 

And all @yield('title') @yield('body') @yield('footer') display the data of the very first value of the $ post variable.

The documentation did not find any solutions. Can anyone have any suggestions?

PS deleted collected views (view: clear) did not help.

  • one
    you absolutely somehow unconventionally decided to use @section . read about @parent , but most likely it will not help you either. try to implement via nested @include - P. Fateev
  • one
    First, do not use the env helper, in places other than configuration, since caching the config will return null. Secondly, there are directives @stack -> @push - Maxim K

0