0

I would like to create a blog with several different divs. I would use a foreach cycle

@foreach($posts as $post)
  <div class="col-lg-12">
    <article class="post">
   <div class="post-background" data-background="{{ Storage::disk('public')->url('post/'.$post->image) }}">
    <div class="post-header">
     <h2 class="post-title"><a href="blog-single.html">{{ $post->title }}</a></h2>
     <ul class="post-meta h5">
      <li>November 18, 2016</li>
      <li><a href="#">Branding</a>, <a href="#">Design</a></li>
      <li><a href="#">3 Comments</a></li>
     </ul>
    </div><a class="post-background-link" href="blog-single.html"></a>
   </div>
  </article>
  </div>
@endforeach

This is the result

But as we know, foreach involves using the same layout. How can I remedy this?

  • Can't you include a dynamic template (algorythm you need) and use this : https://stackoverflow.com/questions/29739745/laravel-blade-passing-variable-with-string-through-include-causes-error – BENARD Patrick Dec 11 '18 at 20:56
  • You could store the layout details of each `post` in the `posts array` – Jean-Marc Zimmer Dec 12 '18 at 09:23

0 Answers0