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 JobApplication $application |
15
|
|
|
* @param string|null $requestedStep If this is null, redirect to the last touched step. |
16
|
|
|
* @return void |
17
|
|
|
*/ |
18
|
|
|
public function show(JobApplication $application, string $requestedStep = null) |
19
|
|
|
{ |
20
|
|
|
$jobApplicationSteps = $application->jobApplicationSteps(); |
21
|
|
|
$stepOrder = [ |
22
|
|
|
'basic', |
23
|
|
|
'experience', |
24
|
|
|
'skills', |
25
|
|
|
'fit', |
26
|
|
|
'review', |
27
|
|
|
'submission' |
28
|
|
|
]; |
29
|
|
|
|
30
|
|
|
$lastTouchedStep = function () use ($stepOrder, $jobApplicationSteps) { |
31
|
|
|
$reversedStepOrder = array_reverse($stepOrder); |
32
|
|
|
foreach ($reversedStepOrder as $step) { |
33
|
|
|
if ($jobApplicationSteps[$step] === 'complete' || |
34
|
|
|
$jobApplicationSteps[$step] === 'error' |
35
|
|
|
) { |
36
|
|
|
return $step; |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
return 'welcome'; |
41
|
|
|
}; |
42
|
|
|
|
43
|
|
|
$customBreadcrumbs = [ |
44
|
|
|
'home' => route('home'), |
|
|
|
|
45
|
|
|
'applications' => route('applications.index'), |
46
|
|
|
$application->job_poster->title => route('jobs.summary', ['jobPoster' => $application->job_poster]), |
47
|
|
|
Lang::get('common/breadcrumbs.application_id', ['id' => $application->id]) => '', |
48
|
|
|
]; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
if ($requestedStep === 'welcome') { |
52
|
|
|
return view('applicant/application-timeline-root') |
|
|
|
|
53
|
|
|
->with([ |
54
|
|
|
'title' => $application->job_poster->title, |
55
|
|
|
'disable_clone_js' => true, |
56
|
|
|
'custom_breadcrumbs' => $customBreadcrumbs, |
57
|
|
|
]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
if ($requestedStep !== null) { |
61
|
|
|
// Show the requested step if it has been touched before. |
62
|
|
|
// Else, redirect the user to the last touched step. |
63
|
|
|
// If no step has been touched, then take them to welcome step. |
64
|
|
|
if (array_key_exists($requestedStep, $jobApplicationSteps) && |
65
|
|
|
($jobApplicationSteps[$requestedStep] === 'complete' || $jobApplicationSteps[$requestedStep] === 'error') |
66
|
|
|
) { |
67
|
|
|
return view('applicant/application-timeline-root') |
68
|
|
|
->with([ |
69
|
|
|
'title' => $application->job_poster->title, |
70
|
|
|
'disable_clone_js' => true, |
71
|
|
|
'custom_breadcrumbs' => $customBreadcrumbs, |
72
|
|
|
]); |
73
|
|
|
} else { |
74
|
|
|
return redirect( |
|
|
|
|
75
|
|
|
route('applications.timeline.step', ['application' => $application, 'step' => $lastTouchedStep()]) |
76
|
|
|
); |
77
|
|
|
} |
78
|
|
|
} else { |
79
|
|
|
// If no step has been entered (/application/id) then redirect user to the last touched step. |
80
|
|
|
// If no step has been touched, then take them to welcome step. |
81
|
|
|
return redirect( |
82
|
|
|
route('applications.timeline.step', ['application' => $application, 'step' => $lastTouchedStep()]) |
83
|
|
|
); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Show the congrats page after application it's validated and submit. |
89
|
|
|
* |
90
|
|
|
* @param \App\Models\JobApplication $application Incoming Job Application object. |
91
|
|
|
* @return \Illuminate\Http\Response |
92
|
|
|
*/ |
93
|
|
|
public function complete(JobApplication $application) |
94
|
|
|
{ |
95
|
|
|
// Dummy Data. |
96
|
|
|
$applicant = $application->applicant; |
97
|
|
|
$jobPoster = $application->job_poster; |
98
|
|
|
|
99
|
|
|
return view( |
|
|
|
|
100
|
|
|
'applicant/application/congrats', |
101
|
|
|
[ |
102
|
|
|
'applicant' => $applicant, |
103
|
|
|
'application' => $application, |
104
|
|
|
'application_template' => Lang::get( |
105
|
|
|
'applicant/application_template', |
106
|
|
|
['security_clearance' => $jobPoster->security_clearance->value ] |
107
|
|
|
), |
108
|
|
|
'jobPoster' => $jobPoster, |
109
|
|
|
] |
110
|
|
|
); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|