xoco70 /
kendozone
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App; |
||
| 4 | |||
| 5 | class Team extends \Xoco70\LaravelTournaments\Models\Team |
||
| 6 | { |
||
| 7 | 9 | protected static function boot() |
|
| 8 | { |
||
| 9 | 9 | parent::boot(); |
|
| 10 | 9 | static::deleting(function ($team) { |
|
| 11 | $teams = Team::where('championship_id', $team->championship_id) |
||
| 12 | ->where('id', '>', $team->id)->get(); |
||
| 13 | foreach ($teams as $team) { |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 14 | $team->short_id--; |
||
| 15 | $team->save(); |
||
| 16 | } |
||
| 17 | 9 | }); |
|
| 18 | 9 | } |
|
| 19 | |||
| 20 | /** |
||
| 21 | * Get all Invitations that belongs to a team |
||
| 22 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
| 23 | */ |
||
| 24 | public function invites() |
||
| 25 | { |
||
| 26 | return $this->morphMany(Invite::class, 'object'); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Get all Invitations that belongs to a team |
||
| 31 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
| 32 | */ |
||
| 33 | public function requests() |
||
| 34 | { |
||
| 35 | return $this->morphMany(Request::class, 'object'); |
||
| 36 | } |
||
| 37 | } |