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

问题描述

我已经应用了具有无限级别子类别的递归关系。我也相应地显示了它。但是问题是我想在下拉列表中索引类别,子类别,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>

递归刀片

<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

预期产量 https://imghostr.com/bf269a_qly

我的输出 https://imghostr.com/1519a8_3he

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)