chrisgrim
5 months ago
723
6
Laravel

Issue with Isset and if statements in blade file

Posted 5 months ago by chrisgrim

Hi I am trying to do an if statement but with a variable that may or may not be there. I tried using

@isset($zipreturns)
                @foreach($zipreturns as $zipreturn)
                    <div>
                        {!!$zipreturn->returns!!}
                    </div>
                @endforeach
            @endisset

but I couldn't figure out how to do an @else if there wasnt a zip return. So I looked online and that suggested

@if (count($zipreturns) > 0)
   @foreach($zipreturns as $zipreturn)
<div>
{!!$zipreturn->returns!!}
</div>
@endforeach
@else
nothing here
@endif

This worked great locally but as soon as I uploaded to my server it gives me the error "Undefined variable: zipreturns.

How would I do an @else statement with isset?

Please sign in or create an account to participate in this conversation.