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