Test Failed
Push — master ( 051cab...019850 )
by Julien
04:18
created

Team::getName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
namespace Xoco70\KendoTournaments\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Team extends Model
8
{
9
    protected $table = 'team';
10
    public $timestamps = true;
11
    protected $fillable = ['short_id', 'name', 'championship_id'];
12
13
    /**
14
     * A Team belongs to a Championship.
15
     *
16
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
17
     */
18
    public function championship()
19
    {
20
        return $this->belongsTo(Championship::class);
21
    }
22
23
    /**
24
     * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
25
     */
26
    public function category()
27
    {
28
        return $this->hasManyThrough(Category::class, Championship::class);
29
    }
30
31
    public function fightersGroups()
32
    {
33
        return $this->belongsToMany(FightersGroup::class, 'round_team')->withTimestamps();
34
    }
35
36
    public function competitors()
37
    {
38
        return $this->belongsToMany(Competitor::class)->withTimestamps();
39
    }
40
41
    public function competitorsWithUser()
42
    {
43
        return $this->belongsToMany(Competitor::class)->with('user');
44
    }
45
46
    public function getName()
47
    {
48
        if ($this == null) return "BYE";
49
        return $this->name;
50
    }
51
52
}
53