david19
8 months ago
472
2
Laravel

Chunk Collection with a @Include

Posted 8 months ago by david19

Hello Team. I love the chunk method, for build a collection in the views. But now i have a @include, and i get error. I try use chunk in a card-deck.

<div class="card-deck">
@foreach ($product_categories as $product_category)
          <li>{{ $product_category->name }}</li>
          <ul>
          @foreach ($product_category->childrenCategories as $childCategory)
          @include('admin.shop.category.child_category', ['child_category' => $childCategory])
          @endforeach
          </ul>
          @endforeach
</div>

The problem is this @include file:

{{ $child_category->name }}
@if ($child_category->product_categories)
    <ul>
      @foreach ($child_category->product_categories as $childCategory)
          @include('admin.shop.category.child_category', ['child_category' => $childCategory])
      @endforeach
    </ul>
@endif
</div>
@foreach($product_categories->chunk(3) as $chunk)
@foreach ($chunk as $product_category)

Maby its not possible use chunk with @include :(

Please sign in or create an account to participate in this conversation.