Reputation:
I'm trying to load some data from the DB into my View and I have coded this:
@forelse($wallets as $wallet)
<td>{{ $wallet->title }}</td>
<td>{{ $wallet->name }}</td>
<td>
@if(($wallet->is_active)==1)
Active
@else
Deactive
@endif
</td>
<td>
@if(($wallet->is_cachable)==1)
Cachable
@else
Un Cachable
@endif
</td>
@endforelse
But I get this:
syntax error, unexpected 'endif' (T_ENDIF)
However, as you can see I have closed the if
s properly by saying: @endif
So what is going wrong here?
Upvotes: 1
Views: 59
Reputation: 3217
Your syntax for @forelse
is wrong.
You need to place an @empty
somewhere in-between which will be rendered when $wallets
is empty:
@forelse($wallets as $wallet)
<td>{{ $wallet->title }}</td>
<td>{{ $wallet->name }}</td>
<td>
@if(($wallet->is_active)==1)
Active
@else
Deactive
@endif
</td>
<td>
@if(($wallet->is_cachable)==1)
Cachable
@else
Un Cachable
@endif
</td>
@empty
<p>No wallet data available</p>
@endforelse
Upvotes: 3