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

Team::hasAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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