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
|
|
|
use App\Models\Lookup\VeteranStatus; |
10
|
|
|
use App\Models\Lookup\PreferredLanguage; |
11
|
|
|
use App\Models\Lookup\CitizenshipDeclaration; |
12
|
|
|
use App\Models\ApplicationReview; |
13
|
|
|
use Illuminate\Notifications\Notifiable; |
14
|
|
|
use App\Events\ApplicationSaved; |
15
|
|
|
use App\Events\ApplicationRetrieved; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class JobApplication |
19
|
|
|
* |
20
|
|
|
* @property int $id |
21
|
|
|
* @property int $job_poster_id |
22
|
|
|
* @property int $application_status_id |
23
|
|
|
* @property int $citizenship_declaration_id |
24
|
|
|
* @property int $veteran_status_id |
25
|
|
|
* @property int $preferred_language_id |
26
|
|
|
* @property int $applicant_id |
27
|
|
|
* @property int $applicant_snapshot_id |
28
|
|
|
* @property string $submission_signature |
29
|
|
|
* @property string $submission_date |
30
|
|
|
* @property \Jenssegers\Date\Date $created_at |
31
|
|
|
* @property \Jenssegers\Date\Date $updated_at |
32
|
|
|
* |
33
|
|
|
* @property \App\Models\Applicant $applicant |
34
|
|
|
* @property \App\Models\Applicant $applicant_snapshot |
35
|
|
|
* @property \App\Models\Lookup\ApplicationStatus $application_status |
36
|
|
|
* @property \App\Models\Lookup\CitizenshipDeclaration $citizenship_declaration |
37
|
|
|
* @property \App\Models\Lookup\VeteranStatus $veteran_status |
38
|
|
|
* @property \App\Models\Lookup\PreferredLanguage $preferred_language |
39
|
|
|
* @property \App\Models\JobPoster $job_poster |
40
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $job_application_answers |
41
|
|
|
* @property \Illuminate\Database\Eloquent\Collection $skill_declarations |
42
|
|
|
* @property \App\Models\ApplicationReview $application_review |
43
|
|
|
*/ |
|
|
|
|
44
|
|
|
class JobApplication extends BaseModel { |
|
|
|
|
45
|
|
|
|
46
|
|
|
use Notifiable; |
|
|
|
|
47
|
|
|
|
48
|
|
|
protected $dispatchesEvents = [ |
49
|
|
|
'retrieved' => ApplicationRetrieved::class, |
50
|
|
|
'saved' => ApplicationSaved::class, |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
protected $casts = [ |
54
|
|
|
'job_poster_id' => 'int', |
55
|
|
|
'application_status_id' => 'int', |
56
|
|
|
'citizenship_declaration_id' => 'int', |
57
|
|
|
'veteran_status_id' => 'int', |
58
|
|
|
'preferred_language_id' => 'int', |
59
|
|
|
'applicant_id' => 'int', |
60
|
|
|
'applicant_snapshot_id' => 'int', |
61
|
|
|
'submission_signature' => 'string', |
62
|
|
|
'submission_date' => 'string', |
63
|
|
|
]; |
64
|
|
|
protected $fillable = [ |
65
|
|
|
'citizenship_declaration_id', |
66
|
|
|
'veteran_status_id', |
67
|
|
|
'preferred_language_id', |
68
|
|
|
'submission_signature', |
69
|
|
|
'submission_date', |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
protected function createApplicantSnapshot($applicant_id) { |
|
|
|
|
73
|
|
|
$applicant = Applicant::where('id', $applicant_id)->firstOrFail(); |
74
|
|
|
|
75
|
|
|
$snapshot = $applicant->replicate(); |
|
|
|
|
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function applicant() { |
|
|
|
|
80
|
|
|
return $this->belongsTo(\App\Models\Applicant::class); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function applicant_snapshot() { |
|
|
|
|
84
|
|
|
return $this->belongsTo(\App\Models\Applicant::class, 'applicant_snapshot_id'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function application_status() { |
|
|
|
|
88
|
|
|
return $this->belongsTo(\App\Models\Lookup\ApplicationStatus::class); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function citizenship_declaration() { |
|
|
|
|
92
|
|
|
return $this->belongsTo(\App\Models\Lookup\CitizenshipDeclaration::class); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function veteran_status() { |
|
|
|
|
96
|
|
|
return $this->belongsTo(\App\Models\Lookup\VeteranStatus::class); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function preferred_language() { |
|
|
|
|
100
|
|
|
return $this->belongsTo(\App\Models\Lookup\PreferredLanguage::class); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function job_poster() { |
|
|
|
|
104
|
|
|
return $this->belongsTo(\App\Models\JobPoster::class); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function job_application_answers() { |
|
|
|
|
108
|
|
|
return $this->hasMany(\App\Models\JobApplicationAnswer::class); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
public function application_review() { |
|
|
|
|
112
|
|
|
return $this->hasOne(ApplicationReview::class); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Return either 'complete', 'incomplete' or 'error', depending on the |
117
|
|
|
* status of the requested section. |
118
|
|
|
* |
119
|
|
|
* @param string $section Should be one of: |
|
|
|
|
120
|
|
|
* 'basics' |
|
|
|
|
121
|
|
|
* 'experience' |
|
|
|
|
122
|
|
|
* 'essential_skills' |
|
|
|
|
123
|
|
|
* 'asset_skills' |
|
|
|
|
124
|
|
|
* 'preview' |
|
|
|
|
125
|
|
|
* |
126
|
|
|
* @return string $status 'complete', 'incomplete' or 'error' |
127
|
|
|
*/ |
128
|
|
|
public function getSectionStatus(string $section) { |
129
|
|
|
//TODO: determine whether sections are complete or opcache_invalid |
130
|
|
|
|
131
|
|
|
$status = 'incomplete'; |
132
|
|
|
switch($section) { |
133
|
|
|
case 'basics': |
134
|
|
|
break; |
135
|
|
|
case 'experience': |
136
|
|
|
break; |
137
|
|
|
case 'essential_skills': |
138
|
|
|
break; |
139
|
|
|
case 'asset_skills': |
140
|
|
|
break; |
141
|
|
|
case 'preview': |
142
|
|
|
break; |
143
|
|
|
default: |
144
|
|
|
$status = 'error'; |
145
|
|
|
break; |
146
|
|
|
} |
147
|
|
|
return $status; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|