1 | <?php |
||
8 | class Fight extends Model |
||
9 | { |
||
10 | /** |
||
11 | * Fight constructor. |
||
12 | * |
||
13 | * @param int $userId1 |
||
14 | * @param int $userId2 |
||
15 | */ |
||
16 | public function __construct($userId1 = null, $userId2 = null) |
||
22 | |||
23 | protected $table = 'fight'; |
||
24 | public $timestamps = true; |
||
25 | |||
26 | protected $fillable = [ |
||
27 | 'group_id', |
||
28 | 'fight_id', |
||
29 | 'c1', |
||
30 | 'c2', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Get First Fighter. |
||
35 | * |
||
36 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
37 | */ |
||
38 | public function group() |
||
42 | |||
43 | /** |
||
44 | * @param FightersGroup|null $group |
||
45 | * |
||
46 | * @return Collection |
||
47 | */ |
||
48 | protected static function getFightersWithByes(FightersGroup $group) |
||
64 | |||
65 | /** |
||
66 | * Get First Fighter. |
||
67 | * |
||
68 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
69 | */ |
||
70 | public function competitor1() |
||
74 | |||
75 | /** |
||
76 | * Get Second Fighter. |
||
77 | * |
||
78 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
79 | */ |
||
80 | public function competitor2() |
||
84 | |||
85 | /** |
||
86 | * Get First Fighter. |
||
87 | * |
||
88 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
89 | */ |
||
90 | public function team1() |
||
94 | |||
95 | |||
96 | /** |
||
97 | * Get Second Fighter. |
||
98 | * |
||
99 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
100 | */ |
||
101 | public function team2() |
||
105 | |||
106 | /** |
||
107 | * Get First Fighter. |
||
108 | * |
||
109 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
110 | */ |
||
111 | public function fighter1() |
||
117 | |||
118 | /** |
||
119 | * Get First Fighter. |
||
120 | * |
||
121 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
122 | */ |
||
123 | public function fighter2() |
||
129 | |||
130 | /** |
||
131 | * @param $numFighter |
||
132 | * @param $attr |
||
133 | * |
||
134 | * @return null|string |
||
135 | */ |
||
136 | public function getFighterAttr($numFighter, $attr) |
||
154 | |||
155 | /** |
||
156 | * @return bool |
||
157 | */ |
||
158 | public function shouldBeInFightList($default) |
||
180 | |||
181 | /** |
||
182 | * return true if fight has 2 fighters ( No BYE ). |
||
183 | * |
||
184 | * @return bool |
||
185 | */ |
||
186 | public function has2Fighters(): bool |
||
190 | |||
191 | /** |
||
192 | * @return bool |
||
193 | */ |
||
194 | private function belongsToFirstRound(): bool |
||
203 | |||
204 | /** |
||
205 | * @return bool |
||
206 | */ |
||
207 | private function dontHave2Fighters() |
||
211 | |||
212 | /** |
||
213 | * @return bool |
||
214 | */ |
||
215 | private function dontHave0Fighters() |
||
219 | |||
220 | /** |
||
221 | * @param Championship $championship |
||
222 | */ |
||
223 | public static function generateFightsId(Championship $championship) |
||
230 | |||
231 | /** |
||
232 | * @param $order |
||
233 | * |
||
234 | * @return int |
||
235 | */ |
||
236 | public function updateShortId($order) |
||
247 | } |
||
248 |