@extends('admin_base') @section('title', 'Categories') @section('style') @endsection @section('content')

Categories

@php // Group categories by parent $groupedCategories = $categories->groupBy('parent_id'); // Closure to render categories recursively (prevents function redeclaration across compiled views) $renderCategories = function($groupedCategories, $parentId = null) use (&$renderCategories) { if (!isset($groupedCategories[$parentId])) return ''; $html = ''; foreach ($groupedCategories[$parentId] as $category) { $html .= ''; $html .= ''; $iconHtml = ''; if (!$parentId && $category->icon) { $iconHtml = '' . e($category->name) . ''; } $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; if (isset($groupedCategories[$category->id])) { $html .= $renderCategories($groupedCategories, $category->id); } } return $html; }; @endphp {!! $renderCategories($groupedCategories) !!}
# Icon Name Products Actions
' . $iconHtml . '' . ($parentId ? '
' . e($category->name) . '
' : e($category->name)) . '
' . $category->products->count() . ''; $html .= '
'; $html .= ' '; $html .= ' '; $html .= '
'; $html .= '
@endsection @section('script') @endsection