1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use App\Models\JobPoster; |
7
|
|
|
use App\Models\Lookup\JobPosterStatus; |
8
|
|
|
use App\Models\Lookup\JobSkillLevel; |
9
|
|
|
use App\Models\Lookup\TalentStream; |
10
|
|
|
use App\Models\Lookup\TalentStreamCategory; |
11
|
|
|
use Illuminate\Support\Facades\Lang; |
12
|
|
|
|
13
|
|
|
class StrategicResponseController extends Controller |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Show the strategic response home page. |
18
|
|
|
* @return \Illuminate\Http\Response |
19
|
|
|
*/ |
20
|
|
|
public function index() |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
$stream_names = TalentStream::all(); |
24
|
|
|
$stream_specialties = TalentStreamCategory::all(); |
25
|
|
|
$job_skill_levels = JobSkillLevel::orderBy('id', 'asc')->get(); |
26
|
|
|
|
27
|
|
|
$strategic_response_id = config('app.strategic_response_department_id'); |
|
|
|
|
28
|
|
|
$strategic_response_jobs = JobPoster::where('department_id', $strategic_response_id) |
29
|
|
|
->where('job_poster_status_id', JobPosterStatus::where('key', 'live')->first()->id) |
30
|
|
|
->get(); |
31
|
|
|
|
32
|
|
|
$streams = []; |
33
|
|
|
// Iterate through all talent streams. |
34
|
|
|
foreach ($stream_names as $stream) { |
35
|
|
|
$stream_jobs = $strategic_response_jobs->where('talent_stream_id', $stream->id); |
36
|
|
|
$specialties = []; |
37
|
|
|
$specialties_count = 0; |
38
|
|
|
foreach ($stream_specialties as $specialty) { |
39
|
|
|
$stream_specialty_jobs = $stream_jobs->where('talent_stream_category_id', $specialty->id); |
40
|
|
|
if ($stream_specialty_jobs->isNotEmpty()) { |
41
|
|
|
$levels = []; |
42
|
|
|
foreach ($job_skill_levels as $level) { |
43
|
|
|
$job = $stream_specialty_jobs->firstWhere('job_skill_level_id', $level->id); |
44
|
|
|
if ($job) { |
45
|
|
|
$levels[$level->name] = ['title' => $level->name, 'job_id' => $job->id]; |
46
|
|
|
$specialties_count += 1; |
47
|
|
|
} else { |
48
|
|
|
$levels[$level->name] = ['title' => $level->name, 'job_id' => null]; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// Push specialty title and associated levels to specialty array. |
53
|
|
|
$specialties[$specialty->name] = [ |
54
|
|
|
'title' => $specialty->name, |
55
|
|
|
'levels' => $levels, |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
if (!empty($specialties)) { |
60
|
|
|
ksort($specialties); |
61
|
|
|
|
62
|
|
|
// Push stream title and specialties to streams array. |
63
|
|
|
$streams[$stream->name] = [ |
64
|
|
|
'title' => $stream->name, |
65
|
|
|
'specialties' => $specialties, |
66
|
|
|
'count' => $specialties_count, |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
ksort($streams); |
71
|
|
|
|
72
|
|
|
return view('response/index/index', [ |
|
|
|
|
73
|
|
|
'response' => Lang::get('response/index'), |
74
|
|
|
'streams' => $streams, |
75
|
|
|
]); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Show the strategic response faq page. |
80
|
|
|
* @return \Illuminate\Http\Response |
81
|
|
|
*/ |
82
|
|
|
public function faq() |
83
|
|
|
{ |
84
|
|
|
return view('response/faq/index', [ |
|
|
|
|
85
|
|
|
'response_faq' => Lang::get('response/faq'), |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|