| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Match extends Model |
||
| 8 | { |
||
| 9 | const WAITING = 0; |
||
| 10 | const RUNNING = 1; |
||
| 11 | const PAUSED = 2; |
||
| 12 | const FINISHED = 3; |
||
| 13 | const NEED_DECISION = 4; |
||
| 14 | const INVALID = 5; |
||
| 15 | const EMPTY_PLACE = -1; |
||
| 16 | |||
| 17 | public function fight() |
||
| 18 | { |
||
| 19 | return $this->belongsTo(Fight::class); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function winner() |
||
| 23 | { |
||
| 24 | return $this->belongsTo(Competitor::class, 'winner_id'); |
||
| 25 | } |
||
| 26 | |||
| 27 | public function assignReferees($referees) |
||
| 28 | { |
||
| 29 | $this->referees()->detach(); |
||
| 30 | foreach ($referees as $position => $referee) { |
||
| 31 | $this->referees()->attach($referee, [ |
||
| 32 | 'position' => $position |
||
| 33 | ]); |
||
| 34 | |||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | public function referees() |
||
| 39 | { |
||
| 40 | return $this->hasMany(Referee::class); |
||
| 41 | } |
||
| 43 |