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