Laravel 如何根据父类别显示或索引空间?
我应用了具有无限级子类别的递归关系。我也相应地展示了它。但问题是我想在下拉列表中索引category,subcategory,sub_subcategory。到目前为止,它还没有索引,下拉列表中的每个类别看起来都像父类别Laravel 如何根据父类别显示或索引空间?,laravel,loops,foreach,Laravel,Loops,Foreach,我应用了具有无限级子类别的递归关系。我也相应地展示了它。但问题是我想在下拉列表中索引category,subcategory,sub_subcategory。到目前为止,它还没有索引,下拉列表中的每个类别看起来都像父类别 <div class="col-sm-6"> <select name="parent_id" class="form-control">
<div class="col-sm-6">
<select name="parent_id" class="form-control">
<option value="">{{translate('Please Select')}}</option>
@foreach($types as $type)
@if($type->parent_id == null || $type->parent_id == 0)
<option value="{{$type->id}}">{{$type->title}}</option>
@endif
@foreach($type->children as $children)
@include('system.business-type.createRecursive',['children'=>$children])
@endforeach
@endforeach
</select>
</div>
{{translate('请选择')}
@foreach($type作为$type)
@如果($type->parent_id==null | |$type->parent_id==0)
{{$type->title}
@恩迪夫
@foreach($type->children as$children)
@包括('system.business type.createRecursive',['children'=>$children])
@endforeach
@endforeach
递归叶片
<option value="{{$children->id}}">{{$children->title}}</option>
@if(count($children->childs) > 0)
@foreach($children->childs as $t)
@include('system.business-type.createRecursive',['children'=>$t])
@endforeach
@endif
{{$children->title}
@如果(计数($children->childs)>0)
@foreach($children->childs as$t)
@包括('system.business type.createRecursive',['children'=>$t])
@endforeach
@恩迪夫
预期产出
我的输出