Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何根据父类别显示或索引空间?_Laravel_Loops_Foreach - Fatal编程技术网

Laravel 如何根据父类别显示或索引空间?

Laravel 如何根据父类别显示或索引空间?,laravel,loops,foreach,Laravel,Loops,Foreach,我应用了具有无限级子类别的递归关系。我也相应地展示了它。但问题是我想在下拉列表中索引category,subcategory,sub_subcategory。到目前为止,它还没有索引,下拉列表中的每个类别看起来都像父类别 <div class="col-sm-6"> <select name="parent_id" class="form-control">

我应用了具有无限级子类别的递归关系。我也相应地展示了它。但问题是我想在下拉列表中索引category,subcategory,sub_subcategory。到目前为止,它还没有索引,下拉列表中的每个类别看起来都像父类别

 <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
@恩迪夫
预期产出

我的输出