@foreach($items as $item)
@php
if ($level === 'category') {
$imgDir = 'images/category/';
$hasChildren = $item->subcategory ? $item->subcategory->where('status','1')->count() : 0;
$href = $hasChildren > 0 ? url('categories?cat=' . $item->id) : $item->getURL();
} elseif ($level === 'sub') {
$imgDir = 'images/subcategory/';
$hasChildren = $item->childcategory ? $item->childcategory->where('status','1')->count() : 0;
$href = $hasChildren > 0 ? url('categories?sub=' . $item->id) : $item->getURL();
} else {
$imgDir = 'images/grandcategory/';
$hasChildren = 0;
$href = $item->getURL();
}
$imgFile = $item->image ?: $item->icon;
$imgPath = $imgFile && file_exists(public_path() . '/' . $imgDir . $imgFile) ? url($imgDir . $imgFile) : null;
@endphp
@if($imgPath)

@else
@endif
@if($hasChildren > 0)
{{ $hasChildren }}
@endif
{{ $item->title }}
@if($hasChildren > 0)
{{ $hasChildren }} {{ $level === 'category' ? __('sub-categories') : __('sections') }}
@else
{{ __('View products') }} →
@endif