1 | <?php |
||
8 | class Fight extends Model |
||
9 | { |
||
10 | /** |
||
11 | * Fight constructor. |
||
12 | * @param int $userId1 |
||
13 | * @param int $userId2 |
||
14 | */ |
||
15 | public function __construct($userId1 = null, $userId2 = null) |
||
20 | |||
21 | protected $table = 'fight'; |
||
22 | public $timestamps = true; |
||
23 | |||
24 | protected $fillable = [ |
||
25 | 'group_id', |
||
26 | 'c1', |
||
27 | 'c2', |
||
28 | ]; |
||
29 | |||
30 | |||
31 | /** |
||
32 | * Get First Fighter. |
||
33 | * |
||
34 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
35 | */ |
||
36 | public function group() |
||
40 | |||
41 | /** |
||
42 | * @param FightersGroup|null $group |
||
43 | * @return Collection |
||
44 | */ |
||
45 | protected static function getFightersWithByes(FightersGroup $group) |
||
59 | |||
60 | /** |
||
61 | * Get First Fighter. |
||
62 | * |
||
63 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
64 | */ |
||
65 | public function competitor1() |
||
69 | |||
70 | /** |
||
71 | * Get Second Fighter. |
||
72 | * |
||
73 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
74 | */ |
||
75 | public function competitor2() |
||
79 | |||
80 | /** |
||
81 | * Get First Fighter. |
||
82 | * |
||
83 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
84 | */ |
||
85 | public function team1() |
||
89 | |||
90 | /** |
||
91 | * Get Second Fighter. |
||
92 | * |
||
93 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
94 | */ |
||
95 | public function team2() |
||
99 | |||
100 | |||
101 | /** |
||
102 | * @param $numFighter |
||
103 | * @param $attr |
||
104 | * @return null|string |
||
105 | */ |
||
106 | public function getFighterAttr($numFighter, $attr) |
||
123 | |||
124 | |||
125 | /** |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function shouldBeInFightList() |
||
145 | |||
146 | /** |
||
147 | * return true if fight has 2 fighters ( No BYE ) |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function has2Fighters(): bool |
||
154 | |||
155 | /** |
||
156 | * @return bool |
||
157 | */ |
||
158 | private function belongsToFirstRound() |
||
164 | |||
165 | /** |
||
166 | * @return bool |
||
167 | */ |
||
168 | private function dontHave2Fighters() |
||
172 | |||
173 | /** |
||
174 | * @return bool |
||
175 | */ |
||
176 | private function dontHave0Fighters() |
||
180 | |||
181 | |||
182 | /** |
||
183 | * @param Championship $championship |
||
184 | */ |
||
185 | public static function generateFightsId(Championship $championship) |
||
192 | |||
193 | /** |
||
194 | * @param $order |
||
195 | * @return int |
||
196 | */ |
||
197 | public function updateShortId($order) |
||
206 | |||
207 | } |