Passed
Push — task/common-translation-packag... ( 398328...094bed )
by Grant
07:16
created

Criteria   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
eloc 28
dl 0
loc 78
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A assessments() 0 3 1
A getLevelNameAttribute() 0 5 1
A getLevelDescriptionAttribute() 0 5 1
A criteria_type() 0 3 1
A skill() 0 3 1
A skill_level() 0 3 1
A job_poster() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use App\Models\BaseModel;
6
use Illuminate\Support\Facades\Lang;
7
use Spatie\Translatable\HasTranslations;
8
9
/**
10
 * Class Criteria
11
 *
12
 * @property int $id
13
 * @property int $criteria_type_id
14
 * @property int $job_poster_id
15
 * @property int $skill_id
16
 * @property int $skill_level_id
17
 * @property \Jenssegers\Date\Date $created_at
18
 * @property \Jenssegers\Date\Date $updated_at
19
 *
20
 * @property \App\Models\Lookup\CriteriaType $criteria_type
21
 * @property \App\Models\JobPoster $job_poster
22
 * @property \App\Models\Skill $skill
23
 * @property \App\Models\Lookup\SkillLevel $skill_level
24
 * @property \Illuminate\Database\Eloquent\Collection[Assessment] $assessments
25
 *
26
 *  Accessors
27
 * @property string $level_name The localized name of the skill level (accounts for skill type).
28
 * @property string $level_description The localized description of the skill level (accounts for skill type).
29
 *
30
 *  Localized Properties:
31
  * @property string $description
32
  * @property string $specificity
33
 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment \Illuminate\Database\Elo...\Collection[Assessment] at position 1 could not be parsed: Expected ']' at position 1, but found '['.
Loading history...
34
class Criteria extends BaseModel
35
{
36
37
    use HasTranslations;
38
39
    public $translatable = ['description', 'specificity'];
1 ignored issue
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
40
41
    protected $table = 'criteria';
1 ignored issue
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
42
43
    protected $casts = [
1 ignored issue
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
44
        'criteria_type_id' => 'int',
45
        'job_poster_id' => 'int',
46
        'skill_id' => 'int',
47
        'skill_level_id' => 'int',
48
    ];
49
    protected $fillable = [
1 ignored issue
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
50
        'skill_id',
51
        'criteria_type_id',
52
        'skill_level_id',
53
    ];
54
    protected $with = [
1 ignored issue
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
55
        'criteria_type',
56
        'skill',
57
        'skill_level'
58
    ];
59
60
    public function criteria_type() //phpcs:ignore
61
    {
62
        return $this->belongsTo(\App\Models\Lookup\CriteriaType::class);
63
    }
64
65
    public function job_poster() //phpcs:ignore
66
    {
67
        return $this->belongsTo(\App\Models\JobPoster::class);
68
    }
69
70
    public function skill()
2 ignored issues
show
introduced by
Method \App\Models\Criteria::skill() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function skill()
Loading history...
71
    {
72
        return $this->belongsTo(\App\Models\Skill::class);
73
    }
74
75
    public function skill_level() //phpcs:ignore
76
    {
77
        return $this->belongsTo(\App\Models\Lookup\SkillLevel::class);
78
    }
79
80
    /**
81
     * Get all assessments for this Criteria, for all Screening Plans.
82
     *
83
     * @return \Illuminate\Database\Eloquent\Collection
84
     */
85
    public function assessments() // phpcs:ignore
86
    {
87
        return $this->hasMany(\App\Models\Assessment::class, 'criterion_id');
88
    }
89
90
    /**
91
     * Get the translated name of this Criteria's required skill level.
92
     *
93
     * @return string
1 ignored issue
show
introduced by
Method \App\Models\Criteria::getLevelNameAttribute() has useless @return annotation.
Loading history...
94
     */
95
    public function getLevelNameAttribute(): string
96
    {
97
        $level = $this->skill_level->name;
98
        $type = $this->skill->skill_type->name;
99
        return Lang::get("common/lookup/skill_level.$level.$type.name");
100
    }
101
102
    /**
103
     * Get the translated description of this Criteria's required skill level.
104
     *
105
     * @return string
1 ignored issue
show
introduced by
Method \App\Models\Criteria::getLevelDescriptionAttribute() has useless @return annotation.
Loading history...
106
     */
107
    public function getLevelDescriptionAttribute() : string
108
    {
109
        $level = $this->skill_level->name;
110
        $type = $this->skill->skill_type->name;
111
        return Lang::get("common/lookup/skill_level.$level.$type.description");
112
    }
113
}
114