|
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\Log; |
|
9
|
|
|
use Illuminate\Support\Facades\Request; |
|
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 $step = null) |
|
20
|
|
|
{ |
|
21
|
|
|
$requestedStep = $step; |
|
22
|
|
|
$jobApplicationSteps = $jobApplication->jobApplicationSteps(); |
|
23
|
|
|
$stepOrder = [ |
|
24
|
|
|
'basic', |
|
25
|
|
|
'experience', |
|
26
|
|
|
'skills-intro' => 'skills', |
|
27
|
|
|
'skills', |
|
28
|
|
|
'fit', |
|
29
|
|
|
'review', |
|
30
|
|
|
'submission' |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
// If the applicant has previously reached the requested step |
|
35
|
|
|
// then return them to the step. |
|
36
|
|
|
|
|
37
|
|
|
if ( |
|
38
|
|
|
$requestedStep !== null && |
|
39
|
|
|
array_key_exists($requestedStep, $jobApplicationSteps) && |
|
40
|
|
|
($jobApplicationSteps[$requestedStep] === 'complete' || $jobApplicationSteps[$requestedStep] === 'error') |
|
41
|
|
|
) { |
|
42
|
|
|
return view('applicant/application-timeline-root') |
|
|
|
|
|
|
43
|
|
|
->with([ |
|
44
|
|
|
'title' => $jobApplication->job_poster->title, // TODO: Check with design what the title should be. |
|
45
|
|
|
'disable_clone_js' => true, |
|
46
|
|
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// If the applicant has not reached the requested step |
|
50
|
|
|
// in the application then redirect back to last touched step. |
|
51
|
|
|
$reversedStepOrder = array_reverse($stepOrder); |
|
52
|
|
|
foreach ($reversedStepOrder as $lastTouchedStep) { |
|
53
|
|
|
if ($jobApplicationSteps[$lastTouchedStep] === 'complete' || $jobApplicationSteps[$lastTouchedStep] === 'error') { |
|
54
|
|
|
return redirect()->route('application.timeline', ['jobApplication' => $jobApplication, 'step' => $lastTouchedStep]); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// If no step has been reached yet it will take applicant to welcome step. |
|
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
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|