@php $categories = null; $categoryRepository = app('Webkul\Category\Repositories\CategoryRepository'); $keyIndex = array_key_first($category); $categoryList = ! is_numeric($keyIndex) ? array_values($category) : []; foreach($category as $index => $categoryDetail) { $categorySlug = $index; if (empty($categoryList)) { $categorySlug = $categoryDetail; } $categories[] = $categoryRepository->findByPath($categorySlug); } @endphp @if (! empty($categories))
@if (isset($categoryList[2])) @else @endif

{{ $categories[0]->name }}

@if (isset($categoryList[0])) @else @endif

{{ $categories[1]->name }}

{{ $categories[2]->name }}

@if (isset($categoryList[3])) @else @endif

{{ $categories[3]->name }}

@if (isset($categoryList[1])) @else @endif
@foreach ($categories as $key => $categoryItem)
@if (isset($categoryList[$key])) @else @endif

{{ $categoryItem->name }}

@endforeach
@endif