Passed
Push — master ( de2a89...024236 )
by Julien
04:22
created

Team::getNameAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 0
1
<?php
2
3
namespace Xoco70\LaravelTournaments\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
    public function competitors()
15
    {
16
        return $this->belongsToMany(Competitor::class)->withTimestamps();
17
    }
18
19
    /**
20
     * Get Team Name
21
     * @return mixed|string
22
     */
23
    public function getNameAttribute()
24
    {
25
        return ($this->hasAttribute('name')) ? $this->attributes['name'] : "";
26
    }
27
    public function hasAttribute($attr)
28
    {
29
        return array_key_exists($attr, $this->attributes);
30
    }
31
}
32