Example #1
0
 public function getRounds($season)
 {
     $rounds = $this->rounds()->where('season_id', '=', $season->id)->get();
     foreach ($rounds as $round) {
         $matches = $round->matches;
         foreach ($matches as $match) {
             $match->homeName = Club::find($match->home_id)->name;
             $match->awayName = Club::find($match->away_id)->name;
             $pair = RefereePair::find($match->first_pair_id);
             if ($pair) {
                 $match->first_ref1 = $pair->ref1_id;
                 $match->first_ref2 = $pair->ref2_id;
             }
             $pair = RefereePair::find($match->second_pair_id);
             if ($pair) {
                 $match->second_ref1 = $pair->ref1_id;
                 $match->second_ref2 = $pair->ref2_id;
             }
         }
         $round['matches'] = $matches;
     }
     $data = array('competition_id' => $this->id, 'rounds' => $rounds);
     return $data;
 }
 public function deletePair(RefereePair $pair)
 {
     $pair->delete();
     return $pair;
 }