1 | <?php |
||
9 | class Championship extends Model |
||
10 | { |
||
11 | use SoftDeletes; |
||
12 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
||
13 | protected $table = 'championship'; |
||
14 | |||
15 | public $timestamps = true; |
||
16 | protected $fillable = [ |
||
17 | 'tournament_id', |
||
18 | 'category_id', |
||
19 | ]; |
||
20 | |||
21 | protected static function boot() |
||
22 | { |
||
23 | parent::boot(); |
||
24 | |||
25 | static::deleting(function ($championship) { |
||
26 | $championship->competitors()->delete(); |
||
27 | $championship->settings()->delete(); |
||
28 | }); |
||
29 | static::restoring(function ($championship) { |
||
30 | $championship->competitors()->restore(); |
||
31 | $championship->settings()->restore(); |
||
32 | }); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * A championship has many Competitors. |
||
37 | * |
||
38 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
39 | */ |
||
40 | public function competitors() |
||
44 | |||
45 | /** |
||
46 | * A championship has many Competitors. |
||
47 | * |
||
48 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
49 | */ |
||
50 | public function competitorsWithUser() |
||
54 | |||
55 | /** |
||
56 | * A championship belongs to a Category. |
||
57 | * |
||
58 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
59 | */ |
||
60 | public function category() |
||
64 | |||
65 | /** |
||
66 | * A championship belongs to a Tournament. |
||
67 | * |
||
68 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
69 | */ |
||
70 | public function tournament() |
||
74 | |||
75 | /** |
||
76 | * Get All competitors from a Championships. |
||
77 | * |
||
78 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
79 | */ |
||
80 | public function users() |
||
86 | |||
87 | /** |
||
88 | * A championship only has 1 Settings. |
||
89 | * |
||
90 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
91 | */ |
||
92 | public function settings() |
||
96 | |||
97 | /** |
||
98 | * A championship has Many Teams. |
||
99 | * |
||
100 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
101 | */ |
||
102 | public function teams() |
||
106 | |||
107 | /** |
||
108 | * Check if Championship has Preliminary Round Configured. |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function hasPreliminary() |
||
116 | |||
117 | /** |
||
118 | * Check if 2nd Round of Championship is Round Robin. |
||
119 | * |
||
120 | * @return bool |
||
121 | */ |
||
122 | public function isPlayOffType() |
||
126 | |||
127 | /** |
||
128 | * Check if 2nd Round of Championship is Direct Elimination. |
||
129 | * |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function isDirectEliminationType() |
||
136 | |||
137 | /** |
||
138 | * A championship has Many Rounds. |
||
139 | * |
||
140 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
141 | */ |
||
142 | public function fightersGroups() |
||
146 | |||
147 | /** |
||
148 | * A championship has Many fights. |
||
149 | * |
||
150 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
151 | */ |
||
152 | public function fights() |
||
156 | |||
157 | /** |
||
158 | * |
||
159 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
160 | */ |
||
161 | public function firstRoundFights() |
||
166 | |||
167 | private function hasNoCustomSettings() |
||
178 | |||
179 | public function buildName() |
||
201 | |||
202 | public function getSettings() |
||
206 | |||
207 | } |
||
208 |