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
|
|
|
*/ |
|
|
|
|
34
|
|
|
class Criteria extends BaseModel |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
use HasTranslations; |
38
|
|
|
|
39
|
|
|
public $translatable = ['description', 'specificity']; |
|
|
|
|
40
|
|
|
|
41
|
|
|
protected $table = 'criteria'; |
|
|
|
|
42
|
|
|
|
43
|
|
|
protected $casts = [ |
|
|
|
|
44
|
|
|
'criteria_type_id' => 'int', |
45
|
|
|
'job_poster_id' => 'int', |
46
|
|
|
'skill_id' => 'int', |
47
|
|
|
'skill_level_id' => 'int', |
48
|
|
|
]; |
49
|
|
|
protected $fillable = [ |
|
|
|
|
50
|
|
|
'skill_id', |
51
|
|
|
'criteria_type_id', |
52
|
|
|
'skill_level_id', |
53
|
|
|
]; |
54
|
|
|
protected $with = [ |
|
|
|
|
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() |
|
|
|
|
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 |
|
|
|
|
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 |
|
|
|
|
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
|
|
|
|