Monday, April 3, 2017

Collection::next() in Laravel 5.4?

My main loop is :

@forelse($championship->fightersGroups as $group)
    @include('layouts.scoresheets.sheet', ['group' => $group])
@empty
    
@endforelse

Now, inside sheet, I have 2 cases:

@if (sizeof($fighters) == 2)
            // Here I need to loop 4 groups instead of 1!
            @include('layouts.scoresheets.competitors_direct_elimination', ['fighters'=>$fighters, 'group'=> $group])
        @else
            @include('layouts.scoresheets.competitors', ['fighters'=>$fighters, 'group'=> $group])
        @endif

Thing is I don't know how to loop on $championship->fightersGroups 4 times in the case sizeof($fighters) == 2

Off course, after looping 4 times in $championship->fightersGroups, 'cursor' should remember where he is, and not repeat himself.

Any idea how to do it???



via Juliatzin del Toro

Advertisement