Completed
Push — master ( cf6760...1f6d44 )
by Julien
02:39
created

Team   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 5
c 5
b 0
f 1
lcom 1
cbo 2
dl 0
loc 34
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fightersGroups() 0 4 1
A competitors() 0 4 1
A getNameAttribute() 0 4 2
A hasAttribute() 0 4 1
1
<?php
2
3
namespace Xoco70\KendoTournaments\Models;
4
5
class Team extends Fighter
6
{
7
    protected $table = 'team';
8
    public $timestamps = true;
9
    protected $fillable = ['short_id', 'name', 'championship_id'];
10
11
12
13
    /**
14
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
15
     */
16
    public function fightersGroups()
17
    {
18
        return $this->belongsToMany(FightersGroup::class, 'fighters_group_team')->withTimestamps();
19
    }
20
21
    public function competitors()
22
    {
23
        return $this->belongsToMany(Competitor::class)->withTimestamps();
24
    }
25
26
    /**
27
     * Get Team Name
28
     * @return mixed|string
29
     */
30
    public function getNameAttribute()
31
    {
32
        return ($this->hasAttribute('name')) ? $this->attributes['name'] : "";
33
    }
34
    public function hasAttribute($attr)
35
    {
36
        return array_key_exists($attr, $this->attributes);
37
    }
38
}
39