@extends('admin.layouts.master') @section('style') @endsection @section('content') @php /** * Render tree rows (đệ quy) trong 1 file blade * @param \Illuminate\Support\Collection|array $items * @param int $level */ $renderRows = function ($items, $level = 0) use (&$renderRows) { $html = ''; foreach ($items as $item) { $indent = str_repeat('', $level); $arrow = $level > 0 ? '' : ''; $statusHtml = (int) ($item->status ?? 0) === 1 ? 'Đã kích hoạt' : 'Chưa kích hoạt'; $editUrl = route('admin.product_categories.edit', $item->slug); $html .= ' ' . e($item->id) . ' ' . $indent . $arrow . e($item->name) . ' ' . $statusHtml . ' '; // children if (!empty($item->children) && count($item->children) > 0) { $html .= $renderRows($item->children, $level + 1); } } return $html; }; @endphp

Danh sách danh mục

{{-- Search theo name --}}
@if (request()->filled('search')) Xóa @endif
{{-- Table --}}
@if (!empty($product_categories) && $product_categories->isNotEmpty()) {!! $renderRows($product_categories, 0) !!} @else @endif
ID Tên danh mục Trạng thái Thao tác
Không có dữ liệu
@endsection @section('script') @endsection