title: Laravel blade check empty foreach
body: <p>I want to check if my foreach is empty so the basic html markup isn't displayed with no results inside. I'm trying to wrap it in an if statement and then if it is empty do nothing else loop the foreach. </p>
  
  <pre><code>@if ($status-&gt;replies === '')
  
  @elseif
  &lt;div class="media-body reply-body"&gt;
      @foreach ($status-&gt;replies as $reply)
          &lt;p&gt;{{ $reply-&gt;body }}&lt;/p&gt;
      @endforeach
  &lt;/div&gt;
  @endif
  
  @if (!(empty($status-&gt;replies))
  &lt;div class="media-body reply-body"&gt;
      @foreach ($status-&gt;replies as $reply)
          &lt;div class="media"&gt;
              &lt;a class="pull-left" href="{{ route('profile.index', ['username' =&gt; $reply-&gt;user-&gt;username]) }}"&gt;
                  &lt;img class="media-object" alt="{{ $reply-&gt;user-&gt;getNameOrUsername() }}" src="{{ $reply-&gt;user-&gt;getAvatarUrl() }}"&gt;
              &lt;/a&gt;
              &lt;div class="media-body"&gt;
                  &lt;h5 class="media-heading"&gt;&lt;a href="{{ route('profile.index', ['username' =&gt; $reply-&gt;user-&gt;username]) }}"&gt;{{ $reply-&gt;user-&gt;getNameOrUsername() }}&lt;/a&gt;&lt;/h5&gt;
                  &lt;p&gt;{{ $reply-&gt;body }}&lt;/p&gt;
                  &lt;ul class="list-inline list-replies"&gt;
                      &lt;li&gt;
                          &lt;a href="{{ route('status.like', ['statusId' =&gt; $reply-&gt;id]) }}"&gt;&lt;i class="fa fa-thumbs-up"&gt;&lt;/i&gt;&lt;/a&gt;
                      {{ $reply-&gt;likes-&gt;count() }} {{ str_plural('like', $reply-&gt;likes-&gt;count()) }}&lt;/li&gt;
                      &lt;li&gt;{{ $reply-&gt;created_at-&gt;diffForHumans() }}&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
              &lt;hr&gt;
          &lt;/div&gt;
      @endforeach
  &lt;/div&gt;
  @endif
  </code></pre>