Passed
Pull Request — master (#46)
by
unknown
04:36
created

Grade::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 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 0
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 Grade extends Model
9
{
10
    public $timestamps = true;
11
    protected $table = 'grade';
12
    protected $fillable = [
13
        'id',
14
        'name',
15
        'order'
16
    ];
17
18
    public static function getAll()
19
    {
20 2
        return Cache::remember('grades', config('constants.GRADE_MINUTES'), function () {
21 2
            return static::all();
22 2
        });
23
    }
24
25
    public static function getAllPlucked()
26
    {
27 10
        return Cache::rememberForever('grades_pluck', function () {
28 10
            return static::pluck('name', 'id');
29 10
        });
30
31
    }
32
33 1
    public function getNameAttribute($name)
34
    {
35 1
        return trans($name);
36
    }
37
38
}