1 | <?php |
||
10 | class Championship extends Model |
||
11 | { |
||
12 | use SoftDeletes; |
||
13 | protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
||
14 | protected $table = 'championship'; |
||
15 | |||
16 | public $timestamps = true; |
||
17 | protected $fillable = [ |
||
18 | 'tournament_id', |
||
19 | 'category_id', |
||
20 | ]; |
||
21 | |||
22 | protected static function boot() |
||
23 | { |
||
24 | parent::boot(); |
||
25 | |||
26 | static::deleting(function ($championship) { |
||
27 | $championship->competitors()->delete(); |
||
28 | $championship->settings()->delete(); |
||
29 | }); |
||
30 | static::restoring(function ($championship) { |
||
31 | $championship->competitors()->restore(); |
||
32 | $championship->settings()->restore(); |
||
33 | }); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * A championship has many Competitors. |
||
38 | * |
||
39 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
40 | */ |
||
41 | public function competitors() |
||
45 | |||
46 | /** |
||
47 | * A championship belongs to a Category. |
||
48 | * |
||
49 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
50 | */ |
||
51 | public function category() |
||
55 | |||
56 | /** |
||
57 | * A championship belongs to a Tournament. |
||
58 | * |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
60 | */ |
||
61 | public function tournament() |
||
65 | |||
66 | /** |
||
67 | * Get All competitors from a Championships. |
||
68 | * |
||
69 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
70 | */ |
||
71 | public function users() |
||
77 | |||
78 | /** |
||
79 | * A championship only has 1 Settings. |
||
80 | * |
||
81 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
82 | */ |
||
83 | public function settings() |
||
87 | |||
88 | /** |
||
89 | * A championship has Many Teams. |
||
90 | * |
||
91 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
92 | */ |
||
93 | public function teams() |
||
97 | |||
98 | /** |
||
99 | * Check if Championship has Preliminary Round Configured. |
||
100 | * |
||
101 | * @return bool |
||
102 | */ |
||
103 | public function hasPreliminary() |
||
107 | |||
108 | /** |
||
109 | * Check if 2nd Round of Championship is Round Robin. |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | public function isRoundRobinType() |
||
117 | |||
118 | /** |
||
119 | * Check if 2nd Round of Championship is Direct Elimination. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | public function isDirectEliminationType() |
||
127 | |||
128 | /** |
||
129 | * A championship has Many Rounds. |
||
130 | * |
||
131 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
132 | */ |
||
133 | public function rounds() |
||
137 | |||
138 | /** |
||
139 | * A championship has Many fights. |
||
140 | * |
||
141 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
142 | */ |
||
143 | public function fights() |
||
147 | |||
148 | public function buildName() |
||
168 | } |
||
169 |