Laravel blade check empty foreach
You should use empty()
@if (!empty($status->replies))
<div class="media-body reply-body">
@foreach ($status->replies as $reply)
<p>{{ $reply->body }}</p>
@endforeach
</div>
@endif
You can use count, but if the array is larger it takes longer, if you only need to know if its empty, empty is the better one to use.
I think you are trying to check whether the array is empty or not.You can do like this :
@if(!$result->isEmpty())
// $result is not empty
@else
// $result is empty
@endif
Reference isEmpty()
Check the documentation for the best result:
@forelse($status->replies as $reply)
<p>{{ $reply->body }}</p>
@empty
<p>No replies</p>
@endforelse