Estoy tratando de cargar algunos datos de la base de datos en mi Vista y he codificado esto:
@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> @endforelsePero me sale esto:
error de sintaxis, 'endif' inesperado (T_ENDIF)
Sin embargo, como puede ver, cerré el if correctamente diciendo: @endif
Entonces, ¿qué está yendo mal aquí?
Su sintaxis para @forelse es incorrecta.
Debe colocar un @empty en algún lugar intermedio que se representará cuando $wallets esté vacío:
@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