Захиалга бүртгэл

@php $i = 0; $types_child = clone $types; $types_subchild = clone $types; @endphp @foreach($types->where('parent_id', 0)->get() as $type)
@php if(count($types_child->where('parent_id', $type->id)->get()) != 0){ drawChildAccordion($type, $types_child, $products, $units); } @endphp
@php $i++; @endphp @endforeach
@php function drawChildAccordion($type, $types, $products, $units){ $type_subchilds = clone $types; echo '
'; foreach($types->where('parent_id', $type->id)->get() as $t){ echo '
'; if(count($types->where('parent_id', $t->id)->get()) == 0){ drawProducts($t->id, $products, $units); }else{ drawChildAccordion($t, $types, $products, $units); } echo '
'; } echo '
'; } function drawProducts($type_id, $products, $units){ foreach($products->where('cat', $type_id)->get() as $p){ echo '
'; if($p->split == 0){ echo '
'; } echo '
'; if($p->split == 1){ echo '
'; for($i = 1; $i < 6; $i++){ echo '
'.$i.' өдөр
'; } echo '
'; } } } @endphp