1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by Reliese Model. |
5
|
|
|
* Date: Thu, 12 Jul 2018 22:39:27 +0000. |
6
|
|
|
*/ |
|
|
|
|
7
|
|
|
|
8
|
|
|
namespace App\Models; |
9
|
|
|
|
10
|
|
|
use App\Models\Lookup\CriteriaTypeTranslation; |
11
|
|
|
use Illuminate\Support\Facades\Lang; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Criteria |
15
|
|
|
* |
16
|
|
|
* @property int $id |
17
|
|
|
* @property int $criteria_type_id |
18
|
|
|
* @property int $job_poster_id |
19
|
|
|
* @property int $skill_id |
20
|
|
|
* @property int $skill_level_id |
21
|
|
|
* @property \Jenssegers\Date\Date $created_at |
22
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
23
|
|
|
* |
24
|
|
|
* @property \App\Models\Lookup\CriteriaType $criteria_type |
25
|
|
|
* @property \App\Models\JobPoster $job_poster |
26
|
|
|
* @property \App\Models\Skill $skill |
27
|
|
|
* @property \App\Models\Lookup\SkillLevel $skill_level |
28
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $criteria_translations |
29
|
|
|
* @property \Illuminate\Database\Eloquent\Collection[Assessment] $assessments |
30
|
|
|
* |
31
|
|
|
* Accessors |
32
|
|
|
* @property string $level_name The localized name of the skill level (accounts for skill type). |
33
|
|
|
* @property string $level_description The localized description of the skill level (accounts for skill type). |
34
|
|
|
* |
35
|
|
|
* Localized Properties: |
36
|
|
|
* @property string $description |
|
|
|
|
37
|
|
|
*/ |
|
|
|
|
38
|
|
|
class Criteria extends BaseModel { |
|
|
|
|
39
|
|
|
|
40
|
|
|
use \Dimsav\Translatable\Translatable; |
|
|
|
|
41
|
|
|
public $translatedAttributes = ['description']; |
42
|
|
|
|
43
|
|
|
protected $table = 'criteria'; |
44
|
|
|
protected $casts = [ |
45
|
|
|
'criteria_type_id' => 'int', |
46
|
|
|
'job_poster_id' => 'int', |
47
|
|
|
'skill_id' => 'int', |
48
|
|
|
'skill_level_id' => 'int', |
49
|
|
|
]; |
50
|
|
|
protected $fillable = [ |
51
|
|
|
'criteria_type_id', |
52
|
|
|
'skill_id', |
53
|
|
|
'skill_level_id', |
54
|
|
|
]; |
55
|
|
|
protected $with = [ |
56
|
|
|
'criteria_type', |
57
|
|
|
'skill', |
58
|
|
|
'skill_level' |
59
|
|
|
]; |
60
|
|
|
|
61
|
2 |
|
public function criteria_type() { |
|
|
|
|
62
|
2 |
|
return $this->belongsTo(\App\Models\Lookup\CriteriaType::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function job_poster() { |
|
|
|
|
66
|
|
|
return $this->belongsTo(\App\Models\JobPoster::class); |
67
|
|
|
} |
68
|
|
|
|
69
|
2 |
|
public function skill() { |
|
|
|
|
70
|
2 |
|
return $this->belongsTo(\App\Models\Skill::class); |
71
|
|
|
} |
72
|
|
|
|
73
|
2 |
|
public function skill_level() { |
|
|
|
|
74
|
2 |
|
return $this->belongsTo(\App\Models\Lookup\SkillLevel::class); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function criteria_translations() { |
|
|
|
|
78
|
|
|
return $this->hasMany(\App\Models\Lookup\CriteriaTypeTranslation::class); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get all assessments for this Criteria, for all Screening Plans. |
83
|
|
|
* |
84
|
|
|
* @return \Illuminate\Database\Eloquent\Collection |
85
|
|
|
*/ |
86
|
|
|
public function assessments() // phpcs:ignore |
87
|
|
|
{ |
88
|
|
|
return $this->hasMany(\App\Models\Assessment::class, 'criterion_id'); |
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the translated name of this Criteria's required skill level. |
93
|
|
|
* |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
|
|
public function getLevelNameAttribute(): string |
97
|
|
|
{ |
98
|
|
|
$level = $this->skill_level->name; |
99
|
|
|
$type = $this->skill->skill_type->name; |
100
|
|
|
return Lang::get("common/lookup/skill_level.$level.$type.name"); |
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Get the translated description of this Criteria's required skill level. |
105
|
|
|
* |
106
|
|
|
* @return string |
107
|
|
|
*/ |
108
|
|
|
public function getLevelDescriptionAttribute() : string |
109
|
|
|
{ |
110
|
|
|
$level = $this->skill_level->name; |
111
|
|
|
$type = $this->skill->skill_type->name; |
112
|
|
|
return Lang::get("common/lookup/skill_level.$level.$type.description"); |
|
|
|
|
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|