If I want to display the addresses of a user in a blade file I do it like this:
@if(!$user->addresses->isEmpty())
<ul>
@foreach ($user->addresses as $address)
<li >
{!! displayText($address->toString()) !!}
</li>
@endforeach
</ul>
@endif
If addresses would be an array instead of an collection I could shorten the code to:
@if(!empty($addresses = $user->addresses))
<ul>
@foreach ($addresses as $address)
<li >
{!! displayText($address->toString()) !!}
</li>
@endforeach
</ul>
@endif
I wonder if there is a better way to check if a collection is empty in a blade file.