Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

423
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!