2017-05-29 61 views
0

我試圖在每行中顯示3個結果。 1結果包含圖片,標題和說明。如果描述是冗長的,則第二行中的第四個結果將會中斷。所以我需要在每一行後給予。我嘗試了下面的代碼,但沒有工作。提前感謝。需要在laravel中的每行之後給出行類5.2

<div class="row"> 
    @if(count($reports['data']) > 0) 
     @foreach($reports['data'] as $reportsUser) 

      <div class="col-md-4 wow"> 
       <article class="post post-2 post-2_mod-c clearfix"> 
        <div class="entry-media"> 

         @if($reportsUser['image']) 

          <img src="{{ asset(App\Http\Controllers\Controller::getThumbPath($reportsUser['image'])) }}" 
           alt="Foto" class="img-responsive" style="width:360px;height:192px;"/> 
         @else 

          <img src="{{asset('images/no_image.jpg')}}" alt="Foto" class="img-responsive"/> 

         @endif 
        </div> 
        <div class="entry-main"> 
         <div class="entry-header"> 
          <h2 class="entry-title ">{{$reportsUser['title']}}</h2> 
         </div> 

         <div class="entry-content"> 
          <p>{!! str_limit($reportsUser['description'],127,"....") !!}</p> 
         </div> 
         <div class="entry-footer"><a href="{{ url('view-report/'.$reportsUser['id'])}}" 
                class="btn-link clsComClrRed">Continue Reading</a></div> 
        </div> 
       </article> 
      </div> 

     @endforeach 
    @endif 
</div> 

回答

1

更改@foreach聲明:

@foreach($reports['data'] as $i => $reportsUser) 

然後,就你的第一個@endforeach(和</div>後),加上之前:

@if ($i % 3 == 2) 
    <div class="clearfix"></div> 
@endif 
+0

謝謝你,它的工作原理:) – Rose

相關問題