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

TournamentLevel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 28
ccs 5
cts 7
cp 0.7143
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllPlucked() 0 4 1
A tournaments() 0 3 1
A getNameAttribute() 0 3 1
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
}