在选项组中显示标签和选项值中的相关值

时间:2021-02-01 07:44:46

标签: laravel

我正在创建结构,其中在每个 optgroup 中显示来自数据库的相关值列表,但以下编码仅显示 optgroup 内循环列表,不显示 plz 需要解决方案

$propertytype=DB::table('property_type')->select('property_type_name','property_type_id')->get();
  <select name="property_sub_type" id="property_sub_type" class="form-control basic-select">
                      @foreach($propertytype as $p_propertytype )
                       <optgroup label="{{$p_propertytype->property_type_name}}">
                         <?php 
                           $property_sub_type=DB::table('property_sub_type')
                                              ->pluck('property_sub_type_name','property_sub_type_id')
                                            ->where('property_sub_type.property_type_id',$p_propertytype->property_type_id);

                                            echo $property_sub_type;
                         ?>
                         @foreach($property_sub_type as $p_propertytype_sub_type)
                         <option value="{{ $id }}">{{$p_propertytype_sub_type}}</option>
                         @endforeach
                       </optgroup>
                       @endforeach
                   </select>

0 个答案:

没有答案
相关问题