I have an empty set of data, in my blade template I check for this via:

```
@if(empty($data))
   It's empty!
@else
   @foreach($data as $asset)
      $asset->alt
   @endforeach
@endif

```

The problem is, I get the error:

```
Trying to get property of non-object

```

But this should not even happen as the else of the if statement should not even run. Why is this happening?

I've checked and 'It's empty' is displayed.