Answers for "multilevel sub categories"

0

multilevel sub categories

<!-- Displaying the current category -->
<li value="{{ $category->id }}">{{ $category->name}}

    <!-- If category has children -->
    @if (count($category->children) > 0)

        <!-- Create a nested unordered list -->
        <ul>

            <!-- Loop through this category's children -->
            @foreach ($category->children as $sub)

                <!-- Call this blade file again (recursive) and pass the current subcategory to it -->
                @include('subcategories', ['category' => $sub])
        
            @endforeach
        </ul>
    @endif
</li>
Posted by: Guest on September-23-2021
0

multilevel sub categories

... 

<!-- Start an unoredered list -->
<ul>

    <!-- Loop through each category -->
    @foreach ($categories as $category)

        <!-- Include subcategories.blade.php file and pass the current category to it -->
        @include('subcategories', ['category' => $category])
    @endforeach
<ul>

...
Posted by: Guest on September-23-2021

Browse Popular Code Answers by Language