1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use App\Models\JobApplication; |
7
|
|
|
use Illuminate\Support\Facades\Lang; |
8
|
|
|
|
9
|
|
|
class ApplicationTimelineController extends Controller |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Display job application. |
13
|
|
|
* |
14
|
|
|
* @param \App\Models\JobApplication $application Incoming Application object. |
15
|
|
|
* @return \Illuminate\Http\Response |
16
|
|
|
*/ |
17
|
|
|
public function show(JobApplication $jobApplication, string $requestedStep = null) |
18
|
|
|
{ |
19
|
|
|
$jobApplicationSteps = $jobApplication->jobApplicationSteps(); |
20
|
|
|
$stepOrder = [ |
21
|
|
|
'basic', |
22
|
|
|
'experience', |
23
|
|
|
'skills', |
24
|
|
|
'fit', |
25
|
|
|
'review', |
26
|
|
|
'submission' |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
$lastTouchedStep = function () use ($stepOrder, $jobApplicationSteps) { |
30
|
|
|
$reversedStepOrder = array_reverse($stepOrder); |
31
|
|
|
foreach ($reversedStepOrder as $step) { |
32
|
|
|
if ($jobApplicationSteps[$step] === 'complete' || |
33
|
|
|
$jobApplicationSteps[$step] === 'error' |
34
|
|
|
) { |
35
|
|
|
return $step; |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return 'welcome'; |
40
|
|
|
}; |
41
|
|
|
|
42
|
|
|
if ($requestedStep === 'welcome') { |
43
|
|
|
return view('applicant/application-timeline-root') |
|
|
|
|
44
|
|
|
->with([ |
45
|
|
|
'title' => $jobApplication->job_poster->title, // TODO: Check with design what the title should be. |
46
|
|
|
'disable_clone_js' => true, |
47
|
|
|
]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
if ($requestedStep !== null) { |
51
|
|
|
// Show the requested step if it has been touched before. |
52
|
|
|
// Else, redirect the user to the last touched step. |
53
|
|
|
// If no step has been touched, then take them to welcome step. |
54
|
|
|
if (array_key_exists($requestedStep, $jobApplicationSteps) && |
55
|
|
|
($jobApplicationSteps[$requestedStep] === 'complete' || $jobApplicationSteps[$requestedStep] === 'error') |
56
|
|
|
) { |
57
|
|
|
return view('applicant/application-timeline-root') |
58
|
|
|
->with([ |
59
|
|
|
'title' => $jobApplication->job_poster->title, // TODO: Check with design what the title should be. |
60
|
|
|
'disable_clone_js' => true, |
61
|
|
|
]); |
62
|
|
|
} else { |
63
|
|
|
return redirect( |
|
|
|
|
64
|
|
|
route('applications.timeline.step', ['jobApplication' => $jobApplication, 'step' => $lastTouchedStep()]) |
|
|
|
|
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} else { |
68
|
|
|
// If no step has been entered (/application/id) then redirect user to the last touched step. |
69
|
|
|
// If no step has been touched, then take them to welcome step. |
70
|
|
|
return redirect( |
71
|
|
|
route('applications.timeline.step', ['jobApplication' => $jobApplication, 'step' => $lastTouchedStep()]) |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Show the congrats page after application it's validated and submit. |
78
|
|
|
* |
79
|
|
|
* @param \App\Models\JobApplication $jobApplication Incoming Job Application object. |
80
|
|
|
* @return \Illuminate\Http\Response |
81
|
|
|
*/ |
82
|
|
|
public function complete(JobApplication $jobApplication) |
83
|
|
|
{ |
84
|
|
|
// Dummy Data. |
85
|
|
|
$applicant = $jobApplication->applicant; |
86
|
|
|
$jobPoster = $jobApplication->job_poster; |
87
|
|
|
|
88
|
|
|
return view( |
|
|
|
|
89
|
|
|
'applicant/application/congrats', |
90
|
|
|
[ |
91
|
|
|
'applicant' => $applicant, |
92
|
|
|
'application' => $jobApplication, |
93
|
|
|
'application_template' => Lang::get( |
94
|
|
|
'applicant/application_template', |
95
|
|
|
['security_clearance' => $jobPoster->security_clearance->value ] |
96
|
|
|
), |
97
|
|
|
'jobPoster' => $jobPoster, |
98
|
|
|
] |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|