1 | <?php |
||
2 | |||
3 | namespace App\Models; |
||
4 | |||
5 | use Backpack\CRUD\app\Models\Traits\CrudTrait; |
||
6 | use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations; |
||
7 | |||
8 | /** |
||
9 | * Class Skill |
||
10 | * |
||
11 | * @property int $id |
||
12 | * @property string $name |
||
13 | * @property string $description |
||
14 | * @property int $skill_type_id |
||
15 | * @property boolean $is_culture_skill |
||
16 | * @property boolean $is_future_skill |
||
17 | * @property \Jenssegers\Date\Date $created_at |
||
18 | * @property \Jenssegers\Date\Date $updated_at |
||
19 | * |
||
20 | * @property \App\Models\Lookup\SkillType $skill_type |
||
21 | * @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
||
22 | * @property \Illuminate\Database\Eloquent\Collection $classifications |
||
23 | * @property \App\Models\ExperienceAward|\App\Models\ExperienceCommunity|\App\Models\ExperienceEducation|\App\Models\ExperiencePersonal|\App\Models\ExperienceWork $experience |
||
24 | * @property \Illuminate\Database\Eloquent\Collection $experience_skills |
||
25 | * @property \Illuminate\Database\Eloquent\Collection $skill_categories |
||
26 | * @property \Illuminate\Database\Eloquent\Collection $applicants |
||
27 | */ |
||
28 | class Skill extends BaseModel |
||
29 | { |
||
30 | use CrudTrait; |
||
31 | use HasTranslations; |
||
32 | |||
33 | protected $casts = [ |
||
34 | 'skill_type_id' => 'int', |
||
35 | 'is_culture_skill' => 'boolean', |
||
36 | 'is_future_skill' => 'boolean', |
||
37 | ]; |
||
38 | |||
39 | protected $fillable = [ |
||
40 | 'name', |
||
41 | 'description', |
||
42 | 'skill_type_id', |
||
43 | 'is_culture_skill', |
||
44 | 'is_future_skill', |
||
45 | 'classifications' |
||
46 | ]; |
||
47 | |||
48 | public $translatable = [ |
||
49 | 'name', |
||
50 | 'description', |
||
51 | ]; |
||
52 | |||
53 | public function skill_type() // phpcs:ignore |
||
54 | { |
||
55 | return $this->belongsTo(\App\Models\Lookup\SkillType::class); |
||
56 | } |
||
57 | |||
58 | public function skill_declarations() // phpcs:ignore |
||
59 | { |
||
60 | return $this->hasMany(\App\Models\SkillDeclaration::class); |
||
61 | 5 | } |
|
62 | |||
63 | 5 | public function classifications() // phpcs:ignore |
|
64 | { |
||
65 | return $this->belongsToMany(\App\Models\Classification::class)->withTimestamps(); |
||
66 | } |
||
67 | |||
68 | // Version 2 application models. |
||
69 | |||
70 | public function experiences_work() // phpcs:ignore |
||
71 | 2 | { |
|
72 | return $this->morphedByMany(\App\Models\ExperienceWork::class, 'experience', 'experience_skills'); |
||
73 | 2 | } |
|
74 | |||
75 | public function experiences_personal() // phpcs:ignore |
||
76 | { |
||
77 | return $this->morphedByMany(\App\Models\ExperiencePersonal::class, 'experience', 'experience_skills'); |
||
78 | } |
||
79 | |||
80 | public function experiences_education() // phpcs:ignore |
||
81 | { |
||
82 | 4 | return $this->morphedByMany(\App\Models\ExperienceEducation::class, 'experience', 'experience_skills'); |
|
83 | } |
||
84 | 4 | ||
85 | 4 | public function experiences_award() // phpcs:ignore |
|
86 | 4 | { |
|
87 | 4 | return $this->morphedByMany(\App\Models\ExperienceAward::class, 'experience', 'experience_skills'); |
|
88 | } |
||
89 | |||
90 | public function experiences_community() // phpcs:ignore |
||
91 | { |
||
92 | return $this->morphedByMany(\App\Models\ExperienceCommunity::class, 'experience', 'experience_skills'); |
||
93 | } |
||
94 | |||
95 | public function experience_skills() // phpcs:ignore |
||
96 | { |
||
97 | return $this->hasMany(\App\Models\ExperienceSkill::class); |
||
98 | } |
||
99 | |||
100 | public function skill_categories() // phpcs:ignore |
||
101 | { |
||
102 | return $this->belongsToMany(\App\Models\SkillCategory::class, 'skill_skill_category'); |
||
103 | } |
||
104 | |||
105 | public function applicants() // phpcs:ignore |
||
106 | { |
||
107 | return $this->belongsToMany(\App\Models\Applicant::class, 'applicant_skill'); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * Check for a null "is_culture_skill" and pass false instead. |
||
112 | * |
||
113 | * @param mixed $value Incoming value for the "is_culture_skill" attribute. |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | public function setIsCultureSkillAttribute($value): void |
||
118 | { |
||
119 | if ($value === null) { |
||
120 | $value = false; |
||
121 | } |
||
122 | $this->attributes['is_culture_skill'] = $value; |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Check for a null "is_future_skill" and pass false instead. |
||
127 | * |
||
128 | * @param mixed $value Incoming value for the "is_future_skill" attribute. |
||
129 | * |
||
130 | * @return void |
||
131 | */ |
||
132 | public function setIsFutureSkillAttribute($value): void |
||
133 | { |
||
134 | if ($value === null) { |
||
135 | $value = false; |
||
136 | } |
||
137 | $this->attributes['is_future_skill'] = $value; |
||
0 ignored issues
–
show
|
|||
138 | } |
||
139 | } |
||
140 |