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

Grade   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 1
wmc 3

3 Methods

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