Team::boot()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.9765

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 1
nop 0
dl 0
loc 9
ccs 3
cts 8
cp 0.375
crap 2.9765
rs 10
c 0
b 0
f 0
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
$team is overwriting one of the parameters of this function.
Loading history...
14
                $team->short_id--;
0 ignored issues
show
Bug introduced by
The property short_id does not seem to exist on App\Team. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
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
}