Roots Discourse

Laravel Blade Chunk method from Collections class

I get an error when I try to use the chunk method (https://laravel.com/docs/5.5/collections#method-chunk). Is that not available with Sage? Or am I not loading it in correctly?

How are you using it? What is the error?

I get the “The site is experiencing technical difficulties.” error. I have tested all the other code and that is the code that breaks it.

@foreach($related_posts->chunk(6) as $chunk)
  <div class="wrapper">
    @foreach($chunk as $related)
      <div class="content"></div>
    @endforeach
  </div>
@endforeach

Where is $related_posts coming from? Sage should support the chunk() method.

I did some tinkering on where the $related_posts was coming from and I think the issue was that I didn’t use the collect() method on the array first.

I was so certain this was something more difficult to figure out; I just needed to reread the documentation closer (with your help). Thanks, @alwaysblank