代码之家  ›  专栏  ›  技术社区  ›  Vpa

使用Laravel在表上显示数据超出边界

  •  0
  • Vpa  · 技术社区  · 6 年前

    this is what I want

    这就是我得到的: what I actual got

    这是我在表中显示的循环:

    <table class="table table-borderless table-sm table_view2">
      <thead>
       <tr class="spaceSmall">
         <td style="width:50%;padding-left: 10px;">NOTES TO ACCOUNT<br>Schedules referred to above and notes attached there to form an integral part of Balance Sheet.<br>This is the Balance Sheet referred to in our Report of even date.</td>
         <td style="width:25%"></td>
         <td style="width:25%"></td>
        </tr>
       </thead>
       <tbody>
        <tr class="spaceSmall">
         <td style="padding-left: 25px;">{{ $auditor->auditor_name }}<br>{{ $auditor->qualification }}<br>Membership No. : {{ $auditor->membership_number }}</td>
        @foreach($tasks->work->company->directors as $director)
         @if($director->pivot->director_type == 'Both' || $director->pivot->director_type == 'Director')
          @if(count($director) == 1)
            <td></td>
            <td>{{ $director->salutation }} {{ $director->first_name }} {{ $director->last_name }}<br>DIRECTOR<br>{{ $director->din }}</td>
          @elseif(count($director) == 2)
            <td>{{ $director->salutation }} {{ $director->first_name }} {{ $director->last_name }}<br>DIRECTOR<br>{{ $director->din }}</td>
          @else
             <td></td>
             <td></td>
          @endif
         @else
            <td></td>
            <td></td>
         @endif
        @endforeach
       </tr>
      </tbody>
     </table>
    

    if 里面的情况 foreach director(s) 他们有。

    提前谢谢

    1 回复  |  直到 6 年前
        1
  •  0
  •   Vpa    6 年前

    我得到了答案,对于任何寻求答案的人,我只是把这条线放在循环之外,然后一切正常。

    @php $countDirector = count($tasks->work->company->directors); @endphp
    

    在我的内心 foreach

    @if($countDirector == 1)
      <td></td>
      <td>{{ $director->salutation }} {{ $director->first_name }} {{ $director->last_name }}<br>DIRECTOR<br>{{ $director->din }}</td>
    @elseif($countDirector == 2)
      <td>{{ $director->salutation }} {{ $director->first_name }} {{ $director->last_name }}<br>DIRECTOR<br>{{ $director->din }}</td>
    @else
       <td></td>
       <td></td>
    @endif
    
    推荐文章