Larvel foreach with pivot

I was able to solve this by creating another query and adding that as a blade derivative.

Blade derivative

Blade::if('teamTourneyStatus', function($tourney, $team){
     $team = $tourney->teams->where('id', $team->id)->first();
        if($team->pivot->status == 1){
            return true;
            return false;

Updated view

@foreach($teams as $team)
  {{-- List teams if already attached --}}

     {{-- Get TourneyTeam status --}}
     @teamTourneyStatus($tourney, $team) "show if true" @endteamTourneyStatus

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top