I am currently trying to set up my blade layout with laravel 5.4 but I seem to be having issues with the @empty statement while using it with loops
The code I am trying to use is:
@foreach ($notifications as $notification)
<li data-for='{{ $notification->lobbyid }}'>
@if ($notification->approved == 1)
<div class='notification-text'><strong>{{ $notification->sentBy }}</strong> wants access to your lobby: \"{{$notification->title}}\".</div>
<div class='notification-actions' id='HI' data-for='{{ $notification->lobbyid }}' data-userid='{{ $notification->userid }}'><span data-type='{ \"as\": \"requesting\", \"action\": 1 }'>Accept</span><span data-type='{ \"as\": \"invited\", \"action\": 0 }'>Deny</span></div>
@else
<div class='notification-text'><strong>{{ $notification->sentBy }}</strong> invites you to join his lobby: \"{{$notification->title}}\".</div>
<div class='notification-actions' id='HI' data-for='{{ $notification->lobbyid }}' data-userid='{{ $notification->userid }}'><span data-type='{ \"as\": \"invited\", \"action\": 1 }'>Accept</span><span data-type='{ \"as\": \"invited\", \"action\": 0 }'>Deny</span></div>
@endif
</li>
@empty
<li>No Notifications</li>
@endforelse
And I get the following error:
Undefined variable: __empty_0
When used separately it works great:
@endforeach
@empty($notifications)
<li>No Notifications</li>
@endempty
But I would like the cleaner syntax like on the laravel documentation.
@foreach ($notifications as $notification)
it should be @forelse not @foreach