1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Models\Course; |
6
|
|
|
use App\Models\Criteria; |
7
|
|
|
use App\Models\Degree; |
8
|
|
|
use App\Models\JobApplication; |
9
|
|
|
use App\Models\JobApplicationAnswer; |
10
|
|
|
use App\Models\JobPoster; |
11
|
|
|
use App\Models\Lookup\ApplicationStatus; |
12
|
|
|
use App\Models\Lookup\CitizenshipDeclaration; |
13
|
|
|
use App\Models\Lookup\PreferredLanguage; |
14
|
|
|
use App\Models\Lookup\ReviewStatus; |
15
|
|
|
use App\Models\Lookup\SecurityClearance; |
16
|
|
|
use App\Models\Lookup\SkillStatus; |
17
|
|
|
use App\Models\Lookup\VeteranStatus; |
18
|
|
|
use App\Models\Skill; |
19
|
|
|
use App\Models\SkillDeclaration; |
20
|
|
|
use App\Models\WorkExperience; |
21
|
|
|
use App\Services\Validation\ApplicationValidator; |
22
|
|
|
use App\Services\Validation\Rules\GovernmentEmailRule; |
23
|
|
|
use Facades\App\Services\WhichPortal; |
24
|
|
|
use Illuminate\Http\Request; |
25
|
|
|
use Illuminate\Http\Resources\Json\JsonResource; |
26
|
|
|
use Illuminate\Support\Facades\Auth; |
27
|
|
|
use Illuminate\Support\Facades\Lang; |
28
|
|
|
use Illuminate\Support\Facades\Log; |
29
|
|
|
|
30
|
|
|
class ApplicationByJobController extends Controller |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* Display a listing of the applications for given jobPoster. |
34
|
|
|
* |
35
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming JobPoster object. |
36
|
|
|
* @return \Illuminate\Http\Response |
37
|
|
|
*/ |
38
|
|
|
public function index(JobPoster $jobPoster) |
39
|
|
|
{ |
40
|
|
|
$jobPoster->loadMissing(['criteria', 'talent_stream_category', 'job_skill_level']); |
41
|
|
|
|
42
|
|
|
$view = 'manager/review_applications'; |
43
|
|
|
$jobTitle = $jobPoster->title; |
44
|
|
|
$disableCloneJs = false; |
45
|
|
|
if ($jobPoster->department_id === config('app.strategic_response_department_id')) { |
|
|
|
|
46
|
|
|
$view = 'response/screening/index'; |
47
|
|
|
// Hacky workaround for Accordion JS firing on the screening page. |
48
|
|
|
$disableCloneJs = true; |
49
|
|
|
if ($jobPoster->talent_stream_category && $jobPoster->job_skill_level) { |
50
|
|
|
$jobTitle = $jobPoster->talent_stream_category->name . ' - ' . $jobPoster->job_skill_level->name; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
$applications = $jobPoster->submitted_applications() |
54
|
|
|
->with([ |
55
|
|
|
'veteran_status', |
56
|
|
|
'citizenship_declaration', |
57
|
|
|
'application_review', |
58
|
|
|
'applicant.user', |
59
|
|
|
]) |
60
|
|
|
->get(); |
61
|
|
|
|
62
|
|
|
$viewData = [ |
63
|
|
|
// Localization Strings. |
64
|
|
|
'jobs_l10n' => Lang::get('manager/job_index'), |
65
|
|
|
'response' => Lang::get('response/screening'), |
66
|
|
|
// Data. |
67
|
|
|
'job' => new JsonResource($jobPoster), |
68
|
|
|
'response_job_title' => $jobTitle, |
69
|
|
|
'job_id' => $jobPoster->id, |
70
|
|
|
'is_hr_portal' => WhichPortal::isHrPortal(), |
71
|
|
|
'portal' => WhichPortal::isHrPortal() ? 'hr' : 'manager', |
72
|
|
|
'applications' => $applications, |
73
|
|
|
'review_statuses' => ReviewStatus::all(), |
74
|
|
|
'isHrAdvisor' => Auth::user()->isHrAdvisor(), |
75
|
|
|
]; |
76
|
|
|
|
77
|
|
|
if ($disableCloneJs) { |
78
|
|
|
$viewData['disable_clone_js'] = true; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return view($view, $viewData); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Return the current applicant's application for a given Job Poster. |
86
|
|
|
* |
87
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming JobPoster object. |
88
|
|
|
* @return mixed|\App\Models\JobApplication |
89
|
|
|
*/ |
90
|
|
|
protected function getApplicationFromJob(JobPoster $jobPoster) |
91
|
|
|
{ |
92
|
|
|
$application = JobApplication::where('applicant_id', Auth::user()->applicant->id) |
93
|
|
|
->where('job_poster_id', $jobPoster->id)->first(); |
94
|
|
|
if ($application == null) { |
95
|
|
|
$application = new JobApplication(); |
96
|
|
|
$application->job_poster_id = $jobPoster->id; |
97
|
|
|
$application->applicant_id = Auth::user()->applicant->id; |
98
|
|
|
$application->application_status_id = ApplicationStatus::where('name', 'draft')->firstOrFail()->id; |
99
|
|
|
$application->save(); |
100
|
|
|
$application->attachSteps(); |
101
|
|
|
} |
102
|
|
|
return $application; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Show the form for editing Application basics for the specified job. |
107
|
|
|
* |
108
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
109
|
|
|
* @return \Illuminate\Http\Response |
110
|
|
|
*/ |
111
|
|
|
public function editBasics(JobPoster $jobPoster) |
112
|
|
|
{ |
113
|
|
|
$applicant = Auth::user()->applicant; |
114
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
115
|
|
|
|
116
|
|
|
// Ensure user has permissions to view and update application. |
117
|
|
|
$this->authorize('view', $application); |
118
|
|
|
$this->authorize('update', $application); |
119
|
|
|
|
120
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
121
|
|
|
? 'applicant/strategic_response_application/application_post_01' |
122
|
|
|
: 'applicant/application_post_01'; |
123
|
|
|
|
124
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
125
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
126
|
|
|
: $jobPoster->title; |
127
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
128
|
|
|
|
129
|
|
|
return view( |
|
|
|
|
130
|
|
|
$viewTemplate, |
131
|
|
|
[ |
132
|
|
|
// Application Template Data. |
133
|
|
|
'application_step' => 1, |
134
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
135
|
|
|
'language_options' => PreferredLanguage::all(), |
136
|
|
|
'citizenship_options' => CitizenshipDeclaration::all(), |
137
|
|
|
'veteran_options' => VeteranStatus::all(), |
138
|
|
|
'security_clearance_options' => SecurityClearance::all(), |
139
|
|
|
'preferred_language_template' => Lang::get('common/preferred_language'), |
140
|
|
|
'citizenship_declaration_template' => Lang::get('common/citizenship_declaration'), |
141
|
|
|
'veteran_status_template' => Lang::get('common/veteran_status'), |
142
|
|
|
'header' => [ |
143
|
|
|
'title' => $headerTitle, |
144
|
|
|
], |
145
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 1), |
146
|
|
|
// Job Data. |
147
|
|
|
'job' => $jobPoster, |
148
|
|
|
// Applicant Data. |
149
|
|
|
'applicant' => $applicant, |
150
|
|
|
'job_application' => $application, |
151
|
|
|
// Submission. |
152
|
|
|
'form_submit_action' => route('job.application.update.1', $jobPoster), |
|
|
|
|
153
|
|
|
'gov_email_pattern' => GovernmentEmailRule::PATTERN |
154
|
|
|
] |
155
|
|
|
); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Show the form for editing Application Experience for the specified job. |
160
|
|
|
* |
161
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
162
|
|
|
* @return \Illuminate\Http\Response |
163
|
|
|
*/ |
164
|
|
|
public function editExperience(JobPoster $jobPoster) |
165
|
|
|
{ |
166
|
|
|
$applicant = Auth::user()->applicant; |
167
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
168
|
|
|
|
169
|
|
|
// Ensure user has permissions to view and update application. |
170
|
|
|
$this->authorize('view', $application); |
171
|
|
|
$this->authorize('update', $application); |
172
|
|
|
|
173
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
174
|
|
|
? 'applicant/strategic_response_application/application_post_02' |
175
|
|
|
: 'applicant/application_post_02'; |
176
|
|
|
|
177
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
178
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
179
|
|
|
: $jobPoster->title; |
180
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
181
|
|
|
|
182
|
|
|
return view( |
|
|
|
|
183
|
|
|
$viewTemplate, |
184
|
|
|
[ |
185
|
|
|
// Application Template Data. |
186
|
|
|
'application_step' => 2, |
187
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
188
|
|
|
'header' => [ |
189
|
|
|
'title' => $headerTitle, |
190
|
|
|
], |
191
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 2), |
192
|
|
|
// Job Data. |
193
|
|
|
'job' => $jobPoster, |
194
|
|
|
// Applicant Data. |
195
|
|
|
'applicant' => $applicant, |
196
|
|
|
'job_application' => $application, |
197
|
|
|
// Submission. |
198
|
|
|
'form_submit_action' => route('job.application.update.2', $jobPoster) |
|
|
|
|
199
|
|
|
] |
200
|
|
|
); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Show the form for editing Application Essential Skills for the specified job. |
205
|
|
|
* |
206
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
207
|
|
|
* @return \Illuminate\Http\Response |
208
|
|
|
*/ |
209
|
|
|
public function editEssentialSkills(JobPoster $jobPoster) |
210
|
|
|
{ |
211
|
|
|
$applicant = Auth::user()->applicant; |
212
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
213
|
|
|
|
214
|
|
|
// Ensure user has permissions to view and update application. |
215
|
|
|
$this->authorize('view', $application); |
216
|
|
|
$this->authorize('update', $application); |
217
|
|
|
|
218
|
|
|
$criteria = $jobPoster->criteria->filter(function ($value, $key) { |
|
|
|
|
219
|
|
|
return $value->criteria_type->name == 'essential' |
220
|
|
|
&& $value->skill->skill_type->name == 'hard'; |
221
|
|
|
}); |
222
|
|
|
|
223
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
224
|
|
|
? 'applicant/strategic_response_application/application_post_03' |
225
|
|
|
: 'applicant/application_post_03'; |
226
|
|
|
|
227
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
228
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
229
|
|
|
: $jobPoster->title; |
230
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
231
|
|
|
|
232
|
|
|
return view( |
|
|
|
|
233
|
|
|
$viewTemplate, |
234
|
|
|
[ |
235
|
|
|
// Application Template Data. |
236
|
|
|
'application_step' => 3, |
237
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
238
|
|
|
'header' => [ |
239
|
|
|
'title' => $headerTitle, |
240
|
|
|
], |
241
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 3), |
242
|
|
|
// Job Data. |
243
|
|
|
'job' => $jobPoster, |
244
|
|
|
// Skills Data. |
245
|
|
|
'skills' => Skill::all(), |
246
|
|
|
'skill_template' => Lang::get('common/skills'), |
247
|
|
|
'criteria' => $criteria, |
248
|
|
|
// Applicant Data. |
249
|
|
|
'applicant' => $applicant, |
250
|
|
|
'job_application' => $application, |
251
|
|
|
// Submission. |
252
|
|
|
'form_submit_action' => route('job.application.update.3', $jobPoster) |
|
|
|
|
253
|
|
|
] |
254
|
|
|
); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* Show the form for editing Application Asset Skills for the specified job. |
259
|
|
|
* |
260
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
261
|
|
|
* @return \Illuminate\Http\Response |
262
|
|
|
*/ |
263
|
|
|
public function editAssetSkills(JobPoster $jobPoster) |
264
|
|
|
{ |
265
|
|
|
$applicant = Auth::user()->applicant; |
266
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
267
|
|
|
|
268
|
|
|
// Ensure user has permissions to view and update application. |
269
|
|
|
$this->authorize('view', $application); |
270
|
|
|
$this->authorize('update', $application); |
271
|
|
|
|
272
|
|
|
$criteria = $jobPoster->criteria->filter(function ($value, $key) { |
|
|
|
|
273
|
|
|
return $value->criteria_type->name == 'asset' |
274
|
|
|
&& $value->skill->skill_type->name == 'hard'; |
275
|
|
|
}); |
276
|
|
|
|
277
|
|
|
|
278
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
279
|
|
|
? 'applicant/strategic_response_application/application_post_04' |
280
|
|
|
: 'applicant/application_post_04'; |
281
|
|
|
|
282
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
283
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
284
|
|
|
: $jobPoster->title; |
285
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
286
|
|
|
|
287
|
|
|
return view( |
|
|
|
|
288
|
|
|
$viewTemplate, |
289
|
|
|
[ |
290
|
|
|
// Application Template Data. |
291
|
|
|
'application_step' => 4, |
292
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
293
|
|
|
'header' => [ |
294
|
|
|
'title' => $headerTitle, |
295
|
|
|
], |
296
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 4), |
297
|
|
|
// Job Data. |
298
|
|
|
'job' => $jobPoster, |
299
|
|
|
// Skills Data. |
300
|
|
|
'skills' => Skill::all(), |
301
|
|
|
'skill_template' => Lang::get('common/skills'), |
302
|
|
|
'criteria' => $criteria, |
303
|
|
|
// Applicant Data. |
304
|
|
|
'applicant' => $applicant, |
305
|
|
|
'job_application' => $application, |
306
|
|
|
// Submission. |
307
|
|
|
'form_submit_action' => route('job.application.update.4', $jobPoster) |
|
|
|
|
308
|
|
|
] |
309
|
|
|
); |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* Show the Application Preview for the application for the specified job. |
314
|
|
|
* |
315
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
316
|
|
|
* @return \Illuminate\Http\Response |
317
|
|
|
*/ |
318
|
|
|
public function preview(JobPoster $jobPoster) |
319
|
|
|
{ |
320
|
|
|
$applicant = Auth::user()->applicant; |
321
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
322
|
|
|
|
323
|
|
|
$this->authorize('view', $application); |
324
|
|
|
|
325
|
|
|
$essential_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
|
|
|
|
326
|
|
|
return $value->criteria_type->name == 'essential' |
327
|
|
|
&& $value->skill->skill_type->name == 'hard'; |
328
|
|
|
}); |
329
|
|
|
$asset_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
|
|
|
|
330
|
|
|
return $value->criteria_type->name == 'asset' |
331
|
|
|
&& $value->skill->skill_type->name == 'hard'; |
332
|
|
|
}); |
333
|
|
|
|
334
|
|
|
$skillDeclarations = $application->isDraft() |
335
|
|
|
? $applicant->skill_declarations |
336
|
|
|
: $application->skill_declarations; |
337
|
|
|
$degrees = $application->isDraft() |
338
|
|
|
? $applicant->degrees |
339
|
|
|
: $application->degrees; |
340
|
|
|
$courses = $application->isDraft() |
341
|
|
|
? $applicant->courses |
342
|
|
|
: $application->courses; |
343
|
|
|
$work_experiences = $application->isDraft() |
344
|
|
|
? $applicant->work_experiences |
345
|
|
|
: $application->work_experiences; |
346
|
|
|
$work_samples = $application->isDraft() |
347
|
|
|
? $applicant->work_samples |
348
|
|
|
: $application->work_samples; |
349
|
|
|
|
350
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
351
|
|
|
? 'applicant/strategic_response_application/application_post_05' |
352
|
|
|
: 'applicant/application_post_05'; |
353
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
354
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
355
|
|
|
: $jobPoster->title; |
356
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
357
|
|
|
|
358
|
|
|
return view( |
|
|
|
|
359
|
|
|
$viewTemplate, |
360
|
|
|
[ |
361
|
|
|
// Application Template Data. |
362
|
|
|
'application_step' => 5, |
363
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
364
|
|
|
'preferred_language_template' => Lang::get('common/preferred_language'), |
365
|
|
|
'citizenship_declaration_template' => Lang::get('common/citizenship_declaration'), |
366
|
|
|
'veteran_status_template' => Lang::get('common/veteran_status'), |
367
|
|
|
'header' => [ |
368
|
|
|
'title' => $headerTitle, |
369
|
|
|
], |
370
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 5), |
371
|
|
|
// Job Data. |
372
|
|
|
'job' => $jobPoster, |
373
|
|
|
// Skills Data. |
374
|
|
|
'skills' => Skill::all(), |
375
|
|
|
'skill_template' => Lang::get('common/skills'), |
376
|
|
|
'essential_criteria' => $essential_criteria, |
377
|
|
|
'asset_criteria' => $asset_criteria, |
378
|
|
|
// Applicant Data. |
379
|
|
|
'applicant' => $applicant, |
380
|
|
|
'job_application' => $application, |
381
|
|
|
'skill_declarations' => $skillDeclarations, |
382
|
|
|
'degrees' => $degrees, |
383
|
|
|
'courses' => $courses, |
384
|
|
|
'work_experiences' => $work_experiences, |
385
|
|
|
'work_samples' => $work_samples, |
386
|
|
|
'is_manager_view' => WhichPortal::isManagerPortal(), |
387
|
|
|
'is_draft' => $application->application_status->name == 'draft', |
388
|
|
|
] |
389
|
|
|
); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* Show the Confirm Submit page for the application for the specified job. |
394
|
|
|
* |
395
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
396
|
|
|
* @return \Illuminate\Http\Response |
397
|
|
|
*/ |
398
|
|
|
public function confirm(JobPoster $jobPoster) |
399
|
|
|
{ |
400
|
|
|
$applicant = Auth::user()->applicant; |
|
|
|
|
401
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
402
|
|
|
|
403
|
|
|
$this->authorize('update', $application); |
404
|
|
|
|
405
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
406
|
|
|
? 'applicant/strategic_response_application/application_post_06' |
407
|
|
|
: 'applicant/application_post_06'; |
408
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
409
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
410
|
|
|
: $jobPoster->title; |
411
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
412
|
|
|
|
413
|
|
|
return view( |
|
|
|
|
414
|
|
|
$viewTemplate, |
415
|
|
|
[ |
416
|
|
|
// Application Template Data. |
417
|
|
|
'application_step' => 6, |
418
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
419
|
|
|
'header' => [ |
420
|
|
|
'title' => $headerTitle, |
421
|
|
|
], |
422
|
|
|
'custom_breadcrumbs' => $this->customBreadcrumbs($jobPoster, 6), |
423
|
|
|
// Used by tracker partial. |
424
|
|
|
'job' => $jobPoster, |
425
|
|
|
'job_application' => $application, |
426
|
|
|
// Submission. |
427
|
|
|
'form_submit_action' => route('job.application.submit', $jobPoster) |
|
|
|
|
428
|
|
|
] |
429
|
|
|
); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Show the application submission information. |
434
|
|
|
* |
435
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
436
|
|
|
* @return \Illuminate\Http\Response |
437
|
|
|
*/ |
438
|
|
|
public function complete(JobPoster $jobPoster) |
439
|
|
|
{ |
440
|
|
|
// Include Applicant Data. |
441
|
|
|
$applicant = Auth::user()->applicant; |
442
|
|
|
// Include Application Data. |
443
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
444
|
|
|
|
445
|
|
|
// Ensure user has permissions to view application. |
446
|
|
|
$this->authorize('view', $application); |
447
|
|
|
|
448
|
|
|
$viewTemplate = $jobPoster->isInStrategicResponseDepartment() |
449
|
|
|
? 'applicant/strategic_response_application/application_post_complete' |
450
|
|
|
: 'applicant/application_post_complete'; |
451
|
|
|
|
452
|
|
|
$jobTitle = $jobPoster->isInStrategicResponseDepartment() |
453
|
|
|
? "{$jobPoster->talent_stream_category->name} - {$jobPoster->job_skill_level->name}" |
454
|
|
|
: $jobPoster->title; |
455
|
|
|
$headerTitle = Lang::get('applicant/application_template')['title'] . ": {$jobTitle}"; |
456
|
|
|
|
457
|
|
|
return view( |
|
|
|
|
458
|
|
|
$viewTemplate, |
459
|
|
|
[ |
460
|
|
|
// Application Template Data. |
461
|
|
|
'application_template' => Lang::get('applicant/application_template'), |
462
|
|
|
'header' => [ |
463
|
|
|
'title' => $headerTitle, |
464
|
|
|
], |
465
|
|
|
// Job Data. |
466
|
|
|
'job' => $jobPoster, |
467
|
|
|
// Applicant Data. |
468
|
|
|
'applicant' => $applicant, |
469
|
|
|
'job_application' => $application |
470
|
|
|
] |
471
|
|
|
); |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
/** |
475
|
|
|
* Update the Application Basics in storage for the specified job. |
476
|
|
|
* |
477
|
|
|
* @param \Illuminate\Http\Request $request Incoming Request object. |
478
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
479
|
|
|
* @return \Illuminate\Http\Response |
480
|
|
|
*/ |
481
|
|
|
public function updateBasics(Request $request, JobPoster $jobPoster) |
482
|
|
|
{ |
483
|
|
|
$applicant = Auth::user()->applicant; |
|
|
|
|
484
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
485
|
|
|
|
486
|
|
|
// Ensure user has permissions to update this application. |
487
|
|
|
$this->authorize('update', $application); |
488
|
|
|
|
489
|
|
|
$application->fill([ |
490
|
|
|
'citizenship_declaration_id' => $request->input('citizenship_declaration_id'), |
491
|
|
|
'veteran_status_id' => $request->input('veteran_status_id'), |
492
|
|
|
'preferred_language_id' => $request->input('preferred_language_id'), |
493
|
|
|
'language_requirement_confirmed' => $request->input('language_requirement_confirmed', false), |
494
|
|
|
|
495
|
|
|
// The following fields are exclusive Strategic Talent Response applications. |
496
|
|
|
'director_name' => $request->input('director_name'), |
497
|
|
|
'director_title' => $request->input('director_title'), |
498
|
|
|
'director_email' => $request->input('director_email'), |
499
|
|
|
'reference_name' => $request->input('reference_name'), |
500
|
|
|
'reference_title' => $request->input('reference_title'), |
501
|
|
|
'reference_email' => $request->input('reference_email'), |
502
|
|
|
'gov_email' => $request->input('gov_email'), |
503
|
|
|
'physical_office_willing' => $request->input('physical_office_willing', false), |
504
|
|
|
'security_clearance_id' => $request->input('security_clearance_id'), |
505
|
|
|
]); |
506
|
|
|
$application->save(); |
507
|
|
|
|
508
|
|
|
$questions = $jobPoster->job_poster_questions; |
509
|
|
|
$questionsInput = $request->input('questions'); |
510
|
|
|
foreach ($questions as $question) { |
511
|
|
|
$answer = null; |
512
|
|
|
if (isset($questionsInput[$question->id])) { |
513
|
|
|
$answer = $questionsInput[$question->id]; |
514
|
|
|
} |
515
|
|
|
$answerObj = $application->job_application_answers |
516
|
|
|
->firstWhere('job_poster_question_id', $question->id); |
517
|
|
|
if ($answerObj == null) { |
518
|
|
|
$answerObj = new JobApplicationAnswer(); |
519
|
|
|
$answerObj->job_poster_question_id = $question->id; |
520
|
|
|
$answerObj->job_application_id = $application->id; |
521
|
|
|
} |
522
|
|
|
$answerObj->answer = $answer; |
523
|
|
|
$answerObj->save(); |
524
|
|
|
} |
525
|
|
|
|
526
|
|
|
// Redirect to correct page. |
527
|
|
|
switch ($request->input('submit')) { |
528
|
|
|
case 'save_and_quit': |
529
|
|
|
case 'save_and_return': |
530
|
|
|
return redirect()->route('applications.index'); |
|
|
|
|
531
|
|
|
break; |
|
|
|
|
532
|
|
|
case 'save_and_continue': |
533
|
|
|
case 'next': |
534
|
|
|
$next_step = $jobPoster->isInStrategicResponseDepartment() ? 3 : 2; |
535
|
|
|
return redirect()->route("job.application.edit.${next_step}", $jobPoster); |
536
|
|
|
break; |
537
|
|
|
default: |
538
|
|
|
return redirect()->back()->withInput(); |
539
|
|
|
} |
540
|
|
|
} |
541
|
|
|
|
542
|
|
|
/** |
543
|
|
|
* Update the Application Basics in storage for the specified job. |
544
|
|
|
* |
545
|
|
|
* @param \Illuminate\Http\Request $request Incoming Request object. |
546
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
547
|
|
|
* @return \Illuminate\Http\Response |
548
|
|
|
*/ |
549
|
|
|
public function updateExperience(Request $request, JobPoster $jobPoster) |
550
|
|
|
{ |
551
|
|
|
$applicant = Auth::user()->applicant; |
552
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
553
|
|
|
|
554
|
|
|
// Ensure user has permissions to update this application. |
555
|
|
|
$this->authorize('update', $application); |
556
|
|
|
|
557
|
|
|
// Record that the user has saved their experience for this application. |
558
|
|
|
$application->experience_saved = true; |
559
|
|
|
$application->save(); |
560
|
|
|
|
561
|
|
|
$degrees = $request->input('degrees'); |
562
|
|
|
|
563
|
|
|
$request->validate([ |
564
|
|
|
'degrees.new.*.degree_type_id' => 'required', |
565
|
|
|
'degrees.new.*.area_of_study' => 'required', |
566
|
|
|
'degrees.new.*.institution' => 'required', |
567
|
|
|
'degrees.new.*.thesis' => 'nullable', |
568
|
|
|
'degrees.new.*.start_date' => 'required|date', |
569
|
|
|
'degrees.new.*.end_date' => 'required|date', |
570
|
|
|
'degrees.new.*.blockcert_url' => 'nullable|string', |
571
|
|
|
]); |
572
|
|
|
|
573
|
|
|
// Save new degrees. |
574
|
|
|
if (isset($degrees['new'])) { |
575
|
|
|
foreach ($degrees['new'] as $degreeInput) { |
576
|
|
|
$degree = new Degree(); |
577
|
|
|
$degree->fill([ |
578
|
|
|
'degree_type_id' => $degreeInput['degree_type_id'], |
579
|
|
|
'area_of_study' => $degreeInput['area_of_study'], |
580
|
|
|
'institution' => $degreeInput['institution'], |
581
|
|
|
'thesis' => $degreeInput['thesis'], |
582
|
|
|
'start_date' => $degreeInput['start_date'], |
583
|
|
|
'end_date' => $degreeInput['end_date'], |
584
|
|
|
'blockcert_url' => $degreeInput['blockcert_url'], |
585
|
|
|
]); |
586
|
|
|
$applicant->degrees()->save($degree); |
587
|
|
|
} |
588
|
|
|
} |
589
|
|
|
|
590
|
|
|
// Update old degrees. |
591
|
|
|
if (isset($degrees['old'])) { |
592
|
|
|
foreach ($degrees['old'] as $id => $degreeInput) { |
593
|
|
|
// Ensure this degree belongs to this applicant. |
594
|
|
|
$degree = $applicant->degrees->firstWhere('id', $id); |
595
|
|
|
if ($degree != null) { |
596
|
|
|
$degree->fill([ |
597
|
|
|
'degree_type_id' => $degreeInput['degree_type_id'], |
598
|
|
|
'area_of_study' => $degreeInput['area_of_study'], |
599
|
|
|
'institution' => $degreeInput['institution'], |
600
|
|
|
'thesis' => $degreeInput['thesis'], |
601
|
|
|
'start_date' => $degreeInput['start_date'], |
602
|
|
|
'end_date' => $degreeInput['end_date'], |
603
|
|
|
'blockcert_url' => $degreeInput['blockcert_url'], |
604
|
|
|
]); |
605
|
|
|
$degree->save(); |
606
|
|
|
} else { |
607
|
|
|
Log::warning("Applicant $applicant->id attempted to update degree with invalid id: $id"); |
608
|
|
|
} |
609
|
|
|
} |
610
|
|
|
} |
611
|
|
|
|
612
|
|
|
$courses = $request->input('courses'); |
613
|
|
|
|
614
|
|
|
$request->validate([ |
615
|
|
|
'courses.new.*.name' => 'required', |
616
|
|
|
'courses.new.*.institution' => 'required', |
617
|
|
|
'courses.new.*.course_status_id' => 'required', |
618
|
|
|
'courses.new.*.start_date' => 'required|date', |
619
|
|
|
'courses.new.*.end_date' => 'required|date', |
620
|
|
|
]); |
621
|
|
|
|
622
|
|
|
// Save new courses. |
623
|
|
|
if (isset($courses['new'])) { |
624
|
|
|
foreach ($courses['new'] as $courseInput) { |
625
|
|
|
$course = new Course(); |
626
|
|
|
$course->fill([ |
627
|
|
|
'name' => $courseInput['name'], |
628
|
|
|
'institution' => $courseInput['institution'], |
629
|
|
|
'course_status_id' => $courseInput['course_status_id'], |
630
|
|
|
'start_date' => $courseInput['start_date'], |
631
|
|
|
'end_date' => $courseInput['end_date'] |
632
|
|
|
]); |
633
|
|
|
$applicant->courses()->save($course); |
634
|
|
|
} |
635
|
|
|
} |
636
|
|
|
|
637
|
|
|
// Update old courses. |
638
|
|
|
if (isset($courses['old'])) { |
639
|
|
|
foreach ($courses['old'] as $id => $courseInput) { |
640
|
|
|
// Ensure this course belongs to this applicant. |
641
|
|
|
$course = $applicant->courses->firstWhere('id', $id); |
642
|
|
|
if ($course != null) { |
643
|
|
|
$course->fill([ |
644
|
|
|
'name' => $courseInput['name'], |
645
|
|
|
'institution' => $courseInput['institution'], |
646
|
|
|
'course_status_id' => $courseInput['course_status_id'], |
647
|
|
|
'start_date' => $courseInput['start_date'], |
648
|
|
|
'end_date' => $courseInput['end_date'] |
649
|
|
|
]); |
650
|
|
|
$course->save(); |
651
|
|
|
} else { |
652
|
|
|
Log::warning("Applicant $applicant->id attempted to update course with invalid id: $id"); |
653
|
|
|
} |
654
|
|
|
} |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
$work_experiences = $request->input('work_experiences'); |
658
|
|
|
|
659
|
|
|
$request->validate([ |
660
|
|
|
'work_experiences.new.*.role' => 'required', |
661
|
|
|
'work_experiences.new.*.company' => 'required', |
662
|
|
|
'work_experiences.new.*.description' => 'required', |
663
|
|
|
'work_experiences.new.*.start_date' => 'required|date', |
664
|
|
|
'work_experiences.new.*.end_date' => 'required|date', |
665
|
|
|
]); |
666
|
|
|
|
667
|
|
|
// Save new work_experiences. |
668
|
|
|
if (isset($work_experiences['new'])) { |
669
|
|
|
foreach ($work_experiences['new'] as $workExperienceInput) { |
670
|
|
|
$workExperience = new WorkExperience(); |
671
|
|
|
$workExperience->fill([ |
672
|
|
|
'role' => $workExperienceInput['role'], |
673
|
|
|
'company' => $workExperienceInput['company'], |
674
|
|
|
'description' => $workExperienceInput['description'], |
675
|
|
|
'start_date' => $workExperienceInput['start_date'], |
676
|
|
|
'end_date' => $workExperienceInput['end_date'] |
677
|
|
|
]); |
678
|
|
|
$applicant->work_experiences()->save($workExperience); |
679
|
|
|
} |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
// Update old work_experiences. |
683
|
|
|
if (isset($work_experiences['old'])) { |
684
|
|
|
foreach ($work_experiences['old'] as $id => $workExperienceInput) { |
685
|
|
|
// Ensure this work_experience belongs to this applicant. |
686
|
|
|
$workExperience = $applicant->work_experiences->firstWhere('id', $id); |
687
|
|
|
if ($workExperience != null) { |
688
|
|
|
$workExperience->fill([ |
689
|
|
|
'role' => $workExperienceInput['role'], |
690
|
|
|
'company' => $workExperienceInput['company'], |
691
|
|
|
'description' => $workExperienceInput['description'], |
692
|
|
|
'start_date' => $workExperienceInput['start_date'], |
693
|
|
|
'end_date' => $workExperienceInput['end_date'] |
694
|
|
|
]); |
695
|
|
|
$workExperience->save(); |
696
|
|
|
} else { |
697
|
|
|
Log::warning("Applicant $applicant->id attempted to update work_experience with invalid id: $id"); |
698
|
|
|
} |
699
|
|
|
} |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
// Redirect to correct page. |
703
|
|
|
switch ($request->input('submit')) { |
704
|
|
|
case 'save_and_quit': |
705
|
|
|
return redirect()->route('applications.index'); |
|
|
|
|
706
|
|
|
break; |
|
|
|
|
707
|
|
|
case 'save_and_continue': |
708
|
|
|
case 'next': |
709
|
|
|
return redirect()->route('job.application.edit.3', $jobPoster); |
710
|
|
|
break; |
711
|
|
|
case 'save_and_return': |
712
|
|
|
return redirect()->route('job.application.edit.1', $jobPoster); |
713
|
|
|
break; |
714
|
|
|
default: |
715
|
|
|
return redirect()->back()->withInput(); |
716
|
|
|
} |
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
/** |
720
|
|
|
* Update the Application Essential Skills in storage for the specified job. |
721
|
|
|
* |
722
|
|
|
* @param \Illuminate\Http\Request $request Incoming Request object. |
723
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
724
|
|
|
* @return \Illuminate\Http\Response |
725
|
|
|
*/ |
726
|
|
|
public function updateEssentialSkills(Request $request, JobPoster $jobPoster) |
727
|
|
|
{ |
728
|
|
|
$applicant = Auth::user()->applicant; |
729
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
730
|
|
|
|
731
|
|
|
// Ensure user has permissions to update this application. |
732
|
|
|
$this->authorize('update', $application); |
733
|
|
|
|
734
|
|
|
$skillDeclarations = $request->input('skill_declarations'); |
735
|
|
|
$claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id; |
736
|
|
|
|
737
|
|
|
// Save new skill declarations. |
738
|
|
|
if (isset($skillDeclarations['new'])) { |
739
|
|
|
foreach ($skillDeclarations['new'] as $skillType => $typeInput) { |
740
|
|
|
foreach ($typeInput as $criterion_id => $skillDeclarationInput) { |
741
|
|
|
$skillDeclaration = new SkillDeclaration(); |
742
|
|
|
$skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id; |
743
|
|
|
$skillDeclaration->skill_status_id = $claimedStatusId; |
744
|
|
|
$skillDeclaration->fill([ |
745
|
|
|
'description' => $skillDeclarationInput['description'], |
746
|
|
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
747
|
|
|
]); |
748
|
|
|
$applicant->skill_declarations()->save($skillDeclaration); |
749
|
|
|
|
750
|
|
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
751
|
|
|
$skillDeclaration->references()->sync($referenceIds); |
752
|
|
|
|
753
|
|
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
754
|
|
|
$skillDeclaration->work_samples()->sync($sampleIds); |
755
|
|
|
} |
756
|
|
|
} |
757
|
|
|
} |
758
|
|
|
|
759
|
|
|
// Update old declarations. |
760
|
|
|
if (isset($skillDeclarations['old'])) { |
761
|
|
|
foreach ($skillDeclarations['old'] as $skillType => $typeInput) { |
762
|
|
|
foreach ($typeInput as $id => $skillDeclarationInput) { |
763
|
|
|
// Ensure this declaration belongs to this applicant. |
764
|
|
|
$skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id); |
765
|
|
|
if ($skillDeclaration != null) { |
766
|
|
|
// skill_id and skill_status cannot be changed. |
767
|
|
|
$skillDeclaration->fill([ |
768
|
|
|
'description' => $skillDeclarationInput['description'], |
769
|
|
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
770
|
|
|
]); |
771
|
|
|
$skillDeclaration->save(); |
772
|
|
|
|
773
|
|
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
774
|
|
|
$skillDeclaration->references()->sync($referenceIds); |
775
|
|
|
|
776
|
|
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
777
|
|
|
$skillDeclaration->work_samples()->sync($sampleIds); |
778
|
|
|
} else { |
779
|
|
|
Log::warning("Applicant $applicant->id attempted to update skill declaration with invalid id: $id"); |
780
|
|
|
} |
781
|
|
|
} |
782
|
|
|
} |
783
|
|
|
} |
784
|
|
|
|
785
|
|
|
// Redirect to correct page. |
786
|
|
|
switch ($request->input('submit')) { |
787
|
|
|
case 'save_and_quit': |
788
|
|
|
return redirect()->route('applications.index'); |
|
|
|
|
789
|
|
|
break; |
|
|
|
|
790
|
|
|
case 'save_and_continue': |
791
|
|
|
case 'next': |
792
|
|
|
return redirect()->route('job.application.edit.4', $jobPoster); |
793
|
|
|
break; |
794
|
|
|
case 'save_and_return': |
795
|
|
|
return redirect()->route('job.application.edit.2', $jobPoster); |
796
|
|
|
break; |
797
|
|
|
default: |
798
|
|
|
return redirect()->back()->withInput(); |
799
|
|
|
} |
800
|
|
|
} |
801
|
|
|
|
802
|
|
|
/** |
803
|
|
|
* Update the Application Asset Skills in storage for the specified job. |
804
|
|
|
* |
805
|
|
|
* @param \Illuminate\Http\Request $request Incoming Request object. |
806
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
807
|
|
|
* @return \Illuminate\Http\Response |
808
|
|
|
*/ |
809
|
|
|
public function updateAssetSkills(Request $request, JobPoster $jobPoster) |
810
|
|
|
{ |
811
|
|
|
$applicant = Auth::user()->applicant; |
812
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
813
|
|
|
|
814
|
|
|
// Ensure user has permissions to update this application. |
815
|
|
|
$this->authorize('update', $application); |
816
|
|
|
|
817
|
|
|
$skillDeclarations = $request->input('skill_declarations'); |
818
|
|
|
$claimedStatusId = SkillStatus::where('name', 'claimed')->firstOrFail()->id; |
819
|
|
|
|
820
|
|
|
// Save new skill declarations. |
821
|
|
|
if (isset($skillDeclarations['new'])) { |
822
|
|
|
foreach ($skillDeclarations['new'] as $skillType => $typeInput) { |
823
|
|
|
foreach ($typeInput as $criterion_id => $skillDeclarationInput) { |
824
|
|
|
$skillDeclaration = new SkillDeclaration(); |
825
|
|
|
$skillDeclaration->skill_id = Criteria::find($criterion_id)->skill->id; |
826
|
|
|
$skillDeclaration->skill_status_id = $claimedStatusId; |
827
|
|
|
$skillDeclaration->fill([ |
828
|
|
|
'description' => $skillDeclarationInput['description'], |
829
|
|
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
830
|
|
|
]); |
831
|
|
|
$applicant->skill_declarations()->save($skillDeclaration); |
832
|
|
|
|
833
|
|
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
834
|
|
|
$skillDeclaration->references()->sync($referenceIds); |
835
|
|
|
|
836
|
|
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
837
|
|
|
$skillDeclaration->work_samples()->sync($sampleIds); |
838
|
|
|
} |
839
|
|
|
} |
840
|
|
|
} |
841
|
|
|
|
842
|
|
|
// Update old declarations. |
843
|
|
|
if (isset($skillDeclarations['old'])) { |
844
|
|
|
foreach ($skillDeclarations['old'] as $skillType => $typeInput) { |
845
|
|
|
foreach ($typeInput as $id => $skillDeclarationInput) { |
846
|
|
|
// Ensure this declaration belongs to this applicant. |
847
|
|
|
$skillDeclaration = $applicant->skill_declarations->firstWhere('id', $id); |
848
|
|
|
if ($skillDeclaration != null) { |
849
|
|
|
// skill_id and skill_status cannot be changed. |
850
|
|
|
$skillDeclaration->fill([ |
851
|
|
|
'description' => $skillDeclarationInput['description'], |
852
|
|
|
'skill_level_id' => isset($skillDeclarationInput['skill_level_id']) ? $skillDeclarationInput['skill_level_id'] : null, |
853
|
|
|
]); |
854
|
|
|
$skillDeclaration->save(); |
855
|
|
|
|
856
|
|
|
$referenceIds = $this->getRelativeIds($skillDeclarationInput, 'references'); |
857
|
|
|
$skillDeclaration->references()->sync($referenceIds); |
858
|
|
|
|
859
|
|
|
$sampleIds = $this->getRelativeIds($skillDeclarationInput, 'samples'); |
860
|
|
|
$skillDeclaration->work_samples()->sync($sampleIds); |
861
|
|
|
} else { |
862
|
|
|
Log::warning("Applicant $applicant->id attempted to update skill declaration with invalid id: $id"); |
863
|
|
|
} |
864
|
|
|
} |
865
|
|
|
} |
866
|
|
|
} |
867
|
|
|
|
868
|
|
|
// Redirect to correct page. |
869
|
|
|
switch ($request->input('submit')) { |
870
|
|
|
case 'save_and_quit': |
871
|
|
|
return redirect()->route('applications.index'); |
|
|
|
|
872
|
|
|
break; |
|
|
|
|
873
|
|
|
case 'save_and_continue': |
874
|
|
|
case 'next': |
875
|
|
|
return redirect()->route('job.application.edit.5', $jobPoster); |
876
|
|
|
break; |
877
|
|
|
case 'save_and_return': |
878
|
|
|
return redirect()->route('job.application.edit.3', $jobPoster); |
879
|
|
|
break; |
880
|
|
|
default: |
881
|
|
|
return redirect()->back()->withInput(); |
882
|
|
|
} |
883
|
|
|
} |
884
|
|
|
|
885
|
|
|
/** |
886
|
|
|
* Submit the Application for the specified job. |
887
|
|
|
* |
888
|
|
|
* @param \Illuminate\Http\Request $request Incoming Request object. |
889
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
890
|
|
|
* @return \Illuminate\Http\Response |
891
|
|
|
*/ |
892
|
|
|
public function submit(Request $request, JobPoster $jobPoster) |
893
|
|
|
{ |
894
|
|
|
$application = $this->getApplicationFromJob($jobPoster); |
895
|
|
|
|
896
|
|
|
// Only complete submission if submit button was pressed. |
897
|
|
|
if ($request->input('submit') == 'submit' && $application->application_status->name == 'draft') { |
898
|
|
|
// Ensure user has permissions to update this application. |
899
|
|
|
$this->authorize('update', $application); |
900
|
|
|
$request->validate([ |
901
|
|
|
'submission_signature' => [ |
902
|
|
|
'required', |
903
|
|
|
'string', |
904
|
|
|
'max:191', |
905
|
|
|
], |
906
|
|
|
'submission_date' => [ |
907
|
|
|
'required', |
908
|
|
|
'string', |
909
|
|
|
'max:191', |
910
|
|
|
] |
911
|
|
|
]); |
912
|
|
|
|
913
|
|
|
// Save any final info. |
914
|
|
|
$application->fill([ |
915
|
|
|
'submission_signature' => $request->input('submission_signature'), |
916
|
|
|
'submission_date' => $request->input('submission_date'), |
917
|
|
|
]); |
918
|
|
|
|
919
|
|
|
// Error out of this process now if application is not complete. |
920
|
|
|
$validator = new ApplicationValidator(); |
921
|
|
|
|
922
|
|
|
$validatorInstance = $validator->validator($application); |
923
|
|
|
if (!$validatorInstance->passes()) { |
924
|
|
|
$userId = $application->applicant->user_id; |
925
|
|
|
$msg = "Application $application->id for user $userId is invalid for submission: " . |
926
|
|
|
implode('; ', $validator->detailedValidatorErrors($application)); |
927
|
|
|
Log::info($msg); |
928
|
|
|
} |
929
|
|
|
$validator->validate($application); |
930
|
|
|
|
931
|
|
|
// Change status to 'submitted'. |
932
|
|
|
$application->application_status_id = ApplicationStatus::where('name', 'submitted')->firstOrFail()->id; |
933
|
|
|
$application->saveProfileSnapshot(); |
934
|
|
|
} |
935
|
|
|
|
936
|
|
|
$application->save(); |
937
|
|
|
|
938
|
|
|
// Redirect to correct page. |
939
|
|
|
switch ($request->input('submit')) { |
940
|
|
|
case 'save_and_quit': |
941
|
|
|
return redirect()->route('applications.index'); |
|
|
|
|
942
|
|
|
break; |
|
|
|
|
943
|
|
|
case 'submit': |
944
|
|
|
return redirect()->route('job.application.complete', $jobPoster); |
945
|
|
|
break; |
946
|
|
|
case 'save_and_return': |
947
|
|
|
return redirect()->route('job.application.edit.4', $jobPoster); |
948
|
|
|
break; |
949
|
|
|
default: |
950
|
|
|
return redirect()->back()->withInput(); |
951
|
|
|
} |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
/** |
955
|
|
|
* Custom breadcrumbs for application process. |
956
|
|
|
* |
957
|
|
|
* @param \App\Models\JobPoster $jobPoster Incoming Job Poster object. |
958
|
|
|
* @param string $application_step Current step in application. |
959
|
|
|
* @return array |
960
|
|
|
*/ |
961
|
|
|
public function customBreadcrumbs(JobPoster $jobPoster, string $application_step) |
962
|
|
|
{ |
963
|
|
|
$step_lang = Lang::get('applicant/application_template.tracker_label'); |
964
|
|
|
return [ |
965
|
|
|
'home' => route('home'), |
|
|
|
|
966
|
|
|
'jobs' => route('jobs.index'), |
967
|
|
|
$jobPoster->title => route('jobs.summary', $jobPoster), |
968
|
|
|
$step_lang . ' ' . $application_step => '' |
969
|
|
|
]; |
970
|
|
|
} |
971
|
|
|
} |
972
|
|
|
|