mercredi 28 juin 2017

@empty giving "Undefined variable: __empty_0"

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=''>
        @if ($notification->approved == 1) 
             <div class='notification-text'><strong></strong> wants access to your lobby:  \"\".</div>
             <div class='notification-actions' id='HI' data-for='' data-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></strong> invites you to join his lobby: \"\".</div>
            <div class='notification-actions' id='HI' data-for='' data-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.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire