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
![]() |
|||
34 | class Criteria extends BaseModel |
||
35 | { |
||
36 | |||
37 | use HasTranslations; |
||
38 | |||
39 | public $translatable = [ |
||
40 | 'description', |
||
41 | 'specificity' |
||
42 | ]; |
||
43 | |||
44 | protected $table = 'criteria'; |
||
45 | |||
46 | protected $casts = [ |
||
47 | 'criteria_type_id' => 'int', |
||
48 | 'job_poster_id' => 'int', |
||
49 | 'skill_id' => 'int', |
||
50 | 'skill_level_id' => 'int', |
||
51 | ]; |
||
52 | protected $fillable = [ |
||
53 | 'skill_id', |
||
54 | 'criteria_type_id', |
||
55 | 'skill_level_id', |
||
56 | 'description', |
||
57 | 'specificity' |
||
58 | ]; |
||
59 | protected $with = [ |
||
60 | 'criteria_type', |
||
61 | 'skill', |
||
62 | 'skill_level' |
||
63 | ]; |
||
64 | |||
65 | public function criteria_type() //phpcs:ignore |
||
66 | 13 | { |
|
67 | return $this->belongsTo(\App\Models\Lookup\CriteriaType::class); |
||
68 | 13 | } |
|
69 | |||
70 | public function job_poster() //phpcs:ignore |
||
71 | { |
||
72 | return $this->belongsTo(\App\Models\JobPoster::class); |
||
73 | } |
||
74 | |||
75 | public function skill() |
||
76 | 13 | { |
|
77 | return $this->belongsTo(\App\Models\Skill::class); |
||
78 | 13 | } |
|
79 | |||
80 | public function skill_level() //phpcs:ignore |
||
81 | 13 | { |
|
82 | return $this->belongsTo(\App\Models\Lookup\SkillLevel::class); |
||
83 | 13 | } |
|
84 | |||
85 | /** |
||
86 | * Get all assessments for this Criteria, for all Screening Plans. |
||
87 | * |
||
88 | * @return \Illuminate\Database\Eloquent\Collection |
||
89 | */ |
||
90 | public function assessments() // phpcs:ignore |
||
91 | { |
||
92 | return $this->hasMany(\App\Models\Assessment::class, 'criterion_id'); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * Get the translated name of this Criteria's required skill level. |
||
97 | * |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getLevelNameAttribute(): string |
||
101 | { |
||
102 | $level = $this->skill_level->name; |
||
103 | $type = $this->skill->skill_type->name; |
||
104 | return Lang::get("common/lookup/skill_level.$level.$type.name"); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Get the translated description of this Criteria's required skill level. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getLevelDescriptionAttribute() : string |
||
113 | { |
||
114 | $level = $this->skill_level->name; |
||
115 | $type = $this->skill->skill_type->name; |
||
116 | return Lang::get("common/lookup/skill_level.$level.$type.description"); |
||
117 | } |
||
118 | } |
||
119 |