双环foreach laravel 5.5刀片

时间:2018-10-25 06:22:17

标签: php laravel

试图在laravel中的select中访问第一个循环中的项目表和第二个循环的值。我该怎么做呢?我收到一个错误:

  

试图获取非对象的属性“ unit_abb”(查看:C:\ xampp \ htdocs \ ein \ IPPS \ resources \ views \ pr-items.blade.php)

这是我的代码: pr-items.blade

@foreach($list as $indexKey => $list)
  <form class="form-horizontal" role="form" method="POST" action="{{ url('/update_items',$list->id) }}" autocomplete="off" >
    {{ csrf_field() }}
    {{ method_field('PATCH') }}
    <input type="hidden" value="{{$list->pr_form_number}}" name='prlist' id='prlist'>
  <tr>
    <th>

    </th>
    <td>
      <input type="text" class="form-control custom-border input-sm" value="{{$list->pr_qty}}" name="qtylist" id="qtylist" >
    </td> 
    <td>
      <select id="department" type="text" class="form-control custom-border input-sm" name="unitlist" id="unitlist">
        @foreach ($units as $key => $newunit)
          @if ($loop->parent->first)
            <option value="{{$newunit->unit_abb}}" @if($newunit->unit_abb == $list->pr_unit) selected @endif>{{$newunit->unit_name}}</option>
          @endif

        @endforeach               
      </select>
    </td>
        <td>
     <input type="text" class="form-control custom-border input-sm" value="{{$list->pr_description}}" name="descriptionlist" id="descriptionlist" >
    </td> 
    <td>
      <input type="text" class="form-control custom-border input-sm money-inp" value="{{$list->pr_cost_per_unit}}" name="cpulist" id="cpulist">
    </td>
    <td>
      <input type="text" class="form-control custom-border input-sm money-inp" value="{{$list->pr_estimated_cost}}" disabled>
    </td> 

    <td class="text-center">
      <button type="submit" class="btn btn-warning btn-sm glyphicon glyphicon-pencil"></button>
      <a class="btn btn-danger btn-sm glyphicon glyphicon-minus" href="{{route('pr.delete',$list->id)}}"></a>
    </td>
    </tr>
    </form> 
@endforeach

0 个答案:

没有答案