2017-05-03 7 views
0

foreach 결과에 데이터가 표시되지 않으면 제목을 숨기려고합니다. 그렇다면 섹션 제목은 어디에 배치해야합니까?블레이드 제목에서 데이터가 비어 있으면 숨겨진 제목

@if(!$similar_posts->isEmpty()) 
    {{ $title }} 
@endif 

유지 :

이 컬렉션 인 경우 당신은 항상 확인할 수있는 코드를

<div class="title"> 
//section title 
    <div class="navigation-bar"> 
     <h3>Title</h3> 
    </div> 

@foreach($similar_posts as $related_post) 
    //data 
@endforeach 

</div> 

감사

+2

가능한 중복 시도 [웅변 모음 : 계산을 빈 감지 (http://stackoverflow.com/questions/20563166/eloquent-collection-counting-and-detect-empty) – Christophvh

답변

0

<div class="title"> 

    @if(! $similar_posts->isEmpty()) 

    //section title 
    <div class="navigation-bar"> 
     <h3>Title</h3> 
    </div> 

    @foreach($similar_posts as $related_post) 
     //data 
    @endforeach 

    @endif 

</div> 
+0

덕분에 @ linuxartisan. 그게 작품이야. – Queen

0

입니다 (안)이 무엇인가를 제목 빈 만 출력이 포함 된 경우 뭔가 비어 있는지 확인하는 방법은 여러 가지가 있음을 염두에두고 this post을 참조하여 가장 적합한 것을 찾으십시오.