skip to Main Content

I’ve updated the packages of my laravel project with "composer update", but after the update i have this error : syntax error, unexpected token "endfor".



  <div wire:loading.remove wire:target="lieuDepart">
   @foreach ($lieuxDepart->where('type','Aéroport') as $lieu)
    <p wire:loading.remove wire:click="appliquerLieuDepart('{{ $lieu->nom }}','{{ $lieu->id }}')"
      x-on:click="lieuDepart='{{ $lieu->nom }}'"
      class="truncate px-2 py-2 cursor-pointer hover:bg-teal-100">
      {{ $lieu->nom }}
    </p>
   @endforeach
  </div>

             

here’s the code.

When i comment out the @foreach loop, it works fine.
I tried to rollback the update but it doesn’t work.
Any solution please ?

Here’s the full error in my debug bar :

[09:40:07] LOG.error: syntax error, unexpected token "endfor" {
    "view": {
        "view": "C:\wamp64\www\Projets\DriveEase\resources\views\livewire\form-accueil.blade.php",
        "data": {
            "errors": "<pre class=sf-dump id=sf-dump-2146158752 data-indent-pad="  "><span class=sf-dump-note>Illuminate\Support\ViewErrorBag</span> {<a class=sf-dump-ref>#1565</a><samp data-depth=1 class=sf-dump-expanded>n  #<span class=sf-dump-protected title="Protected property">bags</span>: []n</samp>}n</pre><script>Sfdump("sf-dump-2146158752", {"maxDepth":3,"maxStringLength":160})</script>n"
        }
    },
    "exception": {}
}

3

Answers


  1. Chosen as BEST ANSWER

    Problem solved !

    I went to recover the older versions of composer.json and composer.lock from github :

    $ git log --oneline composer.json composer.lock
    

    And recovered the previous version :

    $ git checkout a164f4e -- composer.json composer.lock
    

    After that, I committed the files, pushed and downgraded the packages with :

    composer install
    

    Thanks to @DarkBee and @TufayalHossinEmon for their contribution.


  2. Ensure this query $lieuxDepart->where('type', 'Aéroport') successfully fetches data.

    Hopefully, it returns empty or null. Debug that.

    if it doesn’t return any data, you may replace your code with the code below. I hope it will solve your problem.

    <div wire:loading.remove wire:target="lieuDepart">
        @if(!empty($lieuxDepart->where('type','Aéroport')))
        @foreach ($lieuxDepart->where('type','Aéroport') as $lieu)
        <p wire:loading.remove wire:click="appliquerLieuDepart('{{ $lieu->nom }}','{{ $lieu->id }}')" x-on:click="lieuDepart='{{ $lieu->nom }}'" class="truncate px-2 py-2 cursor-pointer hover:bg-teal-100">
            {{ $lieu->nom }}
        </p>
        @endforeach
        @endif
    </div>
    

    OR

    <div wire:loading.remove wire:target="lieuDepart">
        @forelse ($lieuxDepart->where('type','Aéroport') as $lieu)
        <p wire:loading.remove wire:click="appliquerLieuDepart('{{ $lieu->nom }}','{{ $lieu->id }}')" x-on:click="lieuDepart='{{ $lieu->nom }}'" class="truncate px-2 py-2 cursor-pointer hover:bg-teal-100">
            {{ $lieu->nom }}
        </p>
        @empty
        @endforelse
    </div>
    
    Login or Signup to reply.
  3. exactly same boat as you … did you find which package causes this ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search