| @@ 9-49 (lines=41) @@ | ||
| 6 | use Xoco70\LaravelTournaments\Models\Competitor; |
|
| 7 | use Xoco70\LaravelTournaments\Models\FightersGroup; |
|
| 8 | ||
| 9 | class DirectEliminationCompetitorTreeGen extends DirectEliminationTreeGen |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * get Fighter by Id. |
|
| 13 | * |
|
| 14 | * @param $competitorId |
|
| 15 | * |
|
| 16 | * @return Competitor |
|
| 17 | */ |
|
| 18 | protected function getFighter($competitorId) |
|
| 19 | { |
|
| 20 | return Competitor::find($competitorId); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Fighter is the name for competitor or team, depending on the case. |
|
| 25 | * |
|
| 26 | * @return Collection |
|
| 27 | */ |
|
| 28 | protected function getFighters() |
|
| 29 | { |
|
| 30 | return $this->championship->competitors; |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param $group |
|
| 35 | * @param $fighters |
|
| 36 | */ |
|
| 37 | public function syncGroup(FightersGroup $group, $fighters) |
|
| 38 | { |
|
| 39 | return $group->syncCompetitors($fighters); |
|
| 40 | } |
|
| 41 | ||
| 42 | protected function createByeFighter() |
|
| 43 | { |
|
| 44 | return new Competitor(); |
|
| 45 | } |
|
| 46 | ||
| 47 | protected function addFighterToGroup(FightersGroup $group, $competitor) |
|
| 48 | { |
|
| 49 | $group->competitors()->attach($competitor->id); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 9-51 (lines=43) @@ | ||
| 6 | use Xoco70\LaravelTournaments\Models\Competitor; |
|
| 7 | use Xoco70\LaravelTournaments\Models\FightersGroup; |
|
| 8 | ||
| 9 | class PlayOffCompetitorTreeGen extends PlayOffTreeGen |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * get Fighter by Id. |
|
| 13 | * |
|
| 14 | * @param $competitorId |
|
| 15 | * |
|
| 16 | * @return Competitor |
|
| 17 | */ |
|
| 18 | protected function getFighter($competitorId) |
|
| 19 | { |
|
| 20 | return Competitor::find($competitorId); |
|
| 21 | } |
|
| 22 | ||
| 23 | /** |
|
| 24 | * Fighter is the name for competitor or team, depending on the case. |
|
| 25 | * |
|
| 26 | * @return Collection |
|
| 27 | */ |
|
| 28 | protected function getFighters() |
|
| 29 | { |
|
| 30 | return $this->championship->competitors; |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param FightersGroup $group |
|
| 35 | * @param $fighters |
|
| 36 | * |
|
| 37 | * @return FightersGroup |
|
| 38 | */ |
|
| 39 | public function syncGroup(FightersGroup $group, $fighters) |
|
| 40 | { |
|
| 41 | // Add all competitors to Pivot Table |
|
| 42 | return $group->syncCompetitors($fighters); |
|
| 43 | } |
|
| 44 | ||
| 45 | protected function createByeFighter() |
|
| 46 | { |
|
| 47 | return new Competitor(); |
|
| 48 | } |
|
| 49 | ||
| 50 | protected function addFighterToGroup(FightersGroup $group, $competitor) |
|
| 51 | { |
|
| 52 | $group->competitors()->attach($competitor->id); |
|
| 53 | } |
|
| 54 | ||