@php
$categoriesOptions ??= [];
$catDisplayType = data_get($categoriesOptions, 'cat_display_type');
$maxSubCats = (int)data_get($categoriesOptions, 'max_sub_cats');
$apiResult ??= [];
$totalCategories = (int)data_get($apiResult, 'meta.total', 0);
$areCategoriesPagingable = (!empty(data_get($apiResult, 'links.prev')) || !empty(data_get($apiResult, 'links.next')));
$categories ??= [];
$subCategories ??= [];
$category ??= null;
$hasChildren ??= false;
$catId ??= 0; /* The selected category ID */
@endphp
@if (!$hasChildren)
{{-- To append in the form (will replace the category field) --}}
@if (!empty($category))
@if (!empty(data_get($category, 'children')))
{{ data_get($category, 'name') }}
@else
{{ data_get($category, 'name') }}
[ {{ t('Edit') }} ]
@endif
@else
{{ t('select_a_category') }}
@endif
@else
{{-- To append in the modal (will replace the modal content) --}}
@if (!empty($category))
@if ($catDisplayType == 'c_picture_list')
@foreach($categories as $key => $cat)
@php
$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
$_parentId = data_get($cat, 'parent.id', 0);
$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
@endphp
@endforeach
@elseif ($catDisplayType == 'c_bigIcon_list')
@foreach($categories as $key => $cat)
@php
$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
$_parentId = data_get($cat, 'parent.id', 0);
$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
@endphp
@endforeach
@elseif (in_array($catDisplayType, ['cc_normal_list', 'cc_normal_list_s']))
@php
$styled = ($catDisplayType == 'cc_normal_list_s') ? ' styled' : '';
@endphp
@foreach ($categories as $key => $cols)
@foreach ($cols as $iCat)
@php
$randomId = '-' . substr(uniqid(rand(), true), 5, 5);
$_hasChildren = (!empty(data_get($iCat, 'children'))) ? 1 : 0;
$_parentId = data_get($iCat, 'parent.id', 0);
$_hasLink = (data_get($iCat, 'id') != $catId || $_hasChildren == 1);
@endphp
@php
$tmpSubCats = data_get($subCategories, data_get($iCat, 'id')) ?? [];
@endphp
@if (!empty($tmpSubCats))
@foreach ($tmpSubCats as $iSubCat)
@php
$_hasChildren2 = (!empty(data_get($iSubCat, 'children'))) ? 1 : 0;
$_parentId2 = data_get($iSubCat, 'parent.id', 0);
$_hasLink2 = (data_get($iSubCat, 'id') != $catId || $_hasChildren2 == 1);
@endphp
-
@if ($_hasLink2)
@endif
{{ data_get($iSubCat, 'name') }}
@if ($_hasLink2)
@endif
@endforeach
@endif
@endforeach
@endforeach
@else
@php
$listTab = [
'c_border_list' => 'list-border',
];
$catListClass = (isset($listTab[$catDisplayType])) ? 'list ' . $listTab[$catDisplayType] : 'list';
@endphp
@foreach ($categories as $key => $items)
@foreach ($items as $k => $cat)
@php
$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
$_parentId = data_get($cat, 'parent.id', 0);
$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
@endphp
-
@if (in_array(config('settings.list.show_category_icon'), [2, 6, 7, 8]))
@endif
@if ($_hasLink)
@endif
{{ data_get($cat, 'name') }}
@if ($_hasLink)
@endif
@endforeach
@endforeach
@endif
@if ($totalCategories > 0 && $areCategoriesPagingable)