Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

427
Visualizações
Laravel: Weird Unexpected 'endif'

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 ifs properly by saying: @endif

So what is going wrong here?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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

Looping in blade.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda