Passed
Pull Request — master (#53)
by
unknown
05:24
created

TournamentLevel::getNameAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\Cache;
7
8
class TournamentLevel extends Model
9
{
10
11
    public $timestamps = false;
12
    protected $table = 'tournamentLevel';
13
    protected $fillable = [
14
        'id',
15
        'name',
16
    ];
17
18
    public static function getAllPlucked()
19
    {
20 6
        return Cache::remember('level_pluck', config('constants.GRADE_MINUTES'), function () {
21 6
            return static::pluck('name', 'id');
22 6
        });
23
    }
24
25 4
    public function getNameAttribute($name)
26
    {
27 4
        return trans($name);
28
    }
29
30
    /**
31
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
32
     */
33
    public function tournaments()
34
    {
35
        return $this->hasMany('App\Tournament', 'level_id', 'id');
36
    }
37
}