|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Models; |
|
4
|
|
|
|
|
5
|
|
|
use App\Traits\TalentCloudCrudTrait as CrudTrait; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class Applicant |
|
9
|
|
|
* |
|
10
|
|
|
* @property int $id |
|
11
|
|
|
* @property string $personal_website |
|
12
|
|
|
* @property string $tagline |
|
13
|
|
|
* @property string $twitter_username |
|
14
|
|
|
* @property string $linkedin_url |
|
15
|
|
|
* @property int $user_id |
|
16
|
|
|
* @property boolean $is_snapshot |
|
17
|
|
|
* @property int $citizenship_declaration_id |
|
18
|
|
|
* @property int $veteran_status_id |
|
19
|
|
|
* |
|
20
|
|
|
* @property \Jenssegers\Date\Date $created_at |
|
21
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
|
22
|
|
|
* |
|
23
|
|
|
* @property \App\Models\User $user |
|
24
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $applicant_profile_answers |
|
25
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_applications |
|
26
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $submitted_applications |
|
27
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $degrees |
|
28
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $courses |
|
29
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_experiences |
|
30
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
|
31
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $references |
|
32
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $work_samples |
|
33
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $projects |
|
34
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $classifications |
|
35
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skills |
|
36
|
|
|
* |
|
37
|
|
|
* Version 2 application models. |
|
38
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $experiences_work |
|
39
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $experiences_personal |
|
40
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $experiences_education |
|
41
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $experiences_award |
|
42
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $experiences_community |
|
43
|
|
|
*/ |
|
44
|
|
|
class Applicant extends BaseModel |
|
45
|
|
|
{ |
|
46
|
|
|
// Trait for Backpack. |
|
47
|
|
|
use CrudTrait; |
|
48
|
|
|
|
|
49
|
|
|
protected $casts = [ |
|
50
|
|
|
'user_id' => 'int', |
|
51
|
|
|
'personal_website' => 'string', |
|
52
|
|
|
'tagline' => 'string', |
|
53
|
|
|
'twitter_username' => 'string', |
|
54
|
|
|
'linkedin_url' => 'string', |
|
55
|
|
|
'is_snapshot' => 'boolean', |
|
56
|
|
|
'citizenship_declaration_id' => 'int', |
|
57
|
|
|
'veteran_status_id' => 'int', |
|
58
|
|
|
]; |
|
59
|
|
|
protected $fillable = [ |
|
60
|
|
|
'personal_website', |
|
61
|
|
|
'tagline', |
|
62
|
|
|
'twitter_username', |
|
63
|
|
|
'linkedin_url', |
|
64
|
|
|
'citizenship_declaration_id' => 'int', |
|
65
|
|
|
'veteran_status_id' => 'int', |
|
66
|
|
|
]; |
|
67
|
|
|
|
|
68
|
|
|
public function user() |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->belongsTo(\App\Models\User::class); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function applicant_profile_answers() //phpcs:ignore |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->hasMany(\App\Models\ApplicantProfileAnswer::class); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function job_applications() //phpcs:ignore |
|
79
|
|
|
{ |
|
80
|
|
|
if ($this->is_snapshot) { |
|
81
|
|
|
return $this->hasMany(\App\Models\JobApplication::class, 'applicant_snapshot_id'); |
|
82
|
|
|
} |
|
83
|
|
|
return $this->hasMany(\App\Models\JobApplication::class); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Get all of the Job Applications submitted by this applicant |
|
88
|
|
|
* |
|
89
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
90
|
|
|
*/ |
|
91
|
|
|
public function submitted_applications() // phpcs:ignore |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->hasMany(\App\Models\JobApplication::class)->whereDoesntHave('application_status', function ($query): void { |
|
94
|
|
|
$query->where('name', 'draft'); |
|
95
|
|
|
}); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function degrees() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->morphMany(\App\Models\Degree::class, 'degreeable')->orderBy('end_date', 'desc'); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
public function courses() |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->morphMany(\App\Models\Course::class, 'courseable')->orderBy('end_date', 'desc'); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function work_experiences() //phpcs:ignore |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->morphMany(\App\Models\WorkExperience::class, 'experienceable')->orderBy('end_date', 'desc'); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function skill_declarations() //phpcs:ignore |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->morphMany(\App\Models\SkillDeclaration::class, 'skillable'); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function references() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->morphMany(\App\Models\Reference::class, 'referenceable'); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function work_samples() //phpcs:ignore |
|
124
|
|
|
{ |
|
125
|
|
|
return $this->morphMany(\App\Models\WorkSample::class, 'work_sampleable'); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
public function projects() |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->morphMany(\App\Models\Project::class, 'projectable'); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
public function classifications() //phpcs:ignore |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->belongsToMany(\App\Models\Classification::class) |
|
136
|
|
|
->withPivot(['level', 'order']) |
|
137
|
|
|
->as('gov_classification') |
|
138
|
|
|
->withTimestamps(); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
public function skills() // phpcs:ignore |
|
142
|
|
|
{ |
|
143
|
|
|
return $this->belongsToMany(\App\Models\Skill::class, 'applicant_skill'); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
// Version 2 application models. |
|
147
|
|
|
|
|
148
|
|
|
public function experiences_work() //phpcs:ignore |
|
149
|
|
|
{ |
|
150
|
|
|
return $this->morphMany(\App\Models\ExperienceWork::class, 'experienceable') |
|
151
|
|
|
->orderBy('end_date', 'desc'); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function experiences_personal() //phpcs:ignore |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->morphMany(\App\Models\ExperiencePersonal::class, 'experienceable') |
|
157
|
|
|
->orderBy('end_date', 'desc'); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function experiences_education() //phpcs:ignore |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->morphMany(\App\Models\ExperienceEducation::class, 'experienceable') |
|
163
|
|
|
->orderBy('end_date', 'desc'); |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
public function experiences_award() //phpcs:ignore |
|
167
|
|
|
{ |
|
168
|
|
|
return $this->morphMany(\App\Models\ExperienceAward::class, 'experienceable'); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
public function experiences_community() //phpcs:ignore |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->morphMany(\App\Models\ExperienceCommunity::class, 'experienceable') |
|
174
|
|
|
->orderBy('end_date', 'desc'); |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|