GCTC-NTGC /
TalentCloud
| 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\JobPosterStatusTransition; |
||||
| 8 | use App\Services\JobStatusTransitionManager; |
||||
| 9 | use Facades\App\Services\WhichPortal; |
||||
| 10 | use Illuminate\Http\Request; |
||||
| 11 | use Illuminate\Support\Facades\Auth; |
||||
| 12 | use Illuminate\Support\Facades\Lang; |
||||
| 13 | |||||
| 14 | class JobSummaryController extends Controller |
||||
| 15 | { |
||||
| 16 | /** |
||||
| 17 | * Display the specified job summary. |
||||
| 18 | * |
||||
| 19 | * @param \Illuminate\Http\Request $request Incoming request object. |
||||
| 20 | * @param \App\Models\JobPoster $job Job Poster object. |
||||
| 21 | * @return \Illuminate\Http\Response |
||||
| 22 | */ |
||||
| 23 | public function show(Request $request, JobPoster $jobPoster) |
||||
| 24 | { |
||||
| 25 | $user = Auth::user(); |
||||
| 26 | |||||
| 27 | $applications = $jobPoster->submitted_applications; |
||||
| 28 | $advisor = $user->hr_advisor; |
||||
| 29 | $jobIsClaimed = ($advisor !== null) && |
||||
| 30 | $advisor->claimed_job_ids->contains($jobPoster->id); |
||||
| 31 | $hr_advisors = $jobPoster->hr_advisors; |
||||
| 32 | |||||
| 33 | $summaryLang = Lang::get('hr_advisor/job_summary'); |
||||
| 34 | |||||
| 35 | $job_review_data = [ |
||||
| 36 | 'imgSrc' => '/images/job-process-summary-tool-edit.svg', |
||||
| 37 | 'imgAlt' => "{$summaryLang['edit_poster_icon']} {$summaryLang['flat_icons']}", |
||||
| 38 | 'text' => $summaryLang['edit_poster_button'], |
||||
| 39 | 'url' => route(WhichPortal::prefixRoute('jobs.review'), $jobPoster), |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 40 | 'disabled' => false, |
||||
| 41 | ]; |
||||
| 42 | |||||
| 43 | $job_preview_data = [ |
||||
| 44 | 'imgSrc' => '/images/job-process-summary-tool-view.svg', |
||||
| 45 | 'imgAlt' => "{$summaryLang['view_poster_icon']} {$summaryLang['flat_icons']}", |
||||
| 46 | 'text' => $summaryLang['view_poster_button'], |
||||
| 47 | 'url' => route(WhichPortal::prefixRoute('jobs.preview'), $jobPoster), |
||||
| 48 | 'disabled' => false, |
||||
| 49 | ]; |
||||
| 50 | |||||
| 51 | $screening_plan_data = [ |
||||
| 52 | 'imgSrc' => '/images/job-process-summary-tool-screen.svg', |
||||
| 53 | 'imgAlt' => "{$summaryLang['screening_plan_icon']} {$summaryLang['flat_icons']}", |
||||
| 54 | 'text' => $summaryLang['screening_plan_button'], |
||||
| 55 | 'url' => route(WhichPortal::prefixRoute('jobs.screening_plan'), $jobPoster), |
||||
| 56 | 'disabled' => false |
||||
| 57 | ]; |
||||
| 58 | |||||
| 59 | $view_applicants_data = [ |
||||
| 60 | 'imgSrc' => '/images/job-process-summary-tool-applicants.svg', |
||||
| 61 | 'imgAlt' => "{$summaryLang['view_applicants_icon']} {$summaryLang['flat_icons']}", |
||||
| 62 | 'text' => $summaryLang['view_applicants_button'], |
||||
| 63 | 'url' => route(WhichPortal::prefixRoute('jobs.applications'), $jobPoster), |
||||
| 64 | 'disabled' => !$user->can('reviewApplicationsFor', $jobPoster), |
||||
| 65 | ]; |
||||
| 66 | |||||
| 67 | $status = $jobPoster->job_poster_status->name; |
||||
| 68 | $status_description = $jobPoster->job_poster_status->description; |
||||
| 69 | |||||
| 70 | $portal = ''; |
||||
| 71 | if (WhichPortal::isHrPortal()) { |
||||
| 72 | $portal = 'hr'; |
||||
| 73 | $menuLang = Lang::get('hr_advisor/menu'); |
||||
| 74 | } elseif (WhichPortal::isManagerPortal()) { |
||||
| 75 | $portal = 'manager'; |
||||
| 76 | $menuLang = Lang::get('manager/menu'); |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | $transitionManager = new JobStatusTransitionManager(); |
||||
| 80 | $transitionToButton = function (JobPosterStatusTransition $transition) use ($user, $jobPoster, $transitionManager) { |
||||
| 81 | return [ |
||||
| 82 | 'text' => $transition->name, |
||||
| 83 | 'from_status' => $transition->from->name, |
||||
| 84 | 'to_status' => $transition->to->name, |
||||
| 85 | 'url' => route(WhichPortal::prefixRoute('jobs.setJobStatus'), [ |
||||
|
0 ignored issues
–
show
The function
route was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 86 | 'jobPoster' => $jobPoster, |
||||
| 87 | 'status' => $transition->to->key |
||||
| 88 | ]), |
||||
| 89 | 'style' => array_key_exists('button_style', $transition->metadata) |
||||
| 90 | ? $transition->metadata['button_style'] |
||||
| 91 | : 'default', |
||||
| 92 | 'disabled' => !$transitionManager->userCanTransition($user, $transition->from->key, $transition->to->key) |
||||
| 93 | ]; |
||||
| 94 | }; |
||||
| 95 | $unclaimButton = [ |
||||
| 96 | 'unclaim_job' => [ |
||||
| 97 | 'text' => Lang::get('hr_advisor/job_summary.relinquish_button'), |
||||
| 98 | 'url' => route('hr_advisor.jobs.unclaim', $jobPoster), |
||||
| 99 | 'style' => 'stop', |
||||
| 100 | 'disabled' => !$jobIsClaimed, |
||||
| 101 | ] |
||||
| 102 | ]; |
||||
| 103 | |||||
| 104 | $buttonGroups = []; |
||||
| 105 | |||||
| 106 | $transitionButtons = $transitionManager->legalTransitions($jobPoster->job_poster_status->key) |
||||
| 107 | ->map($transitionToButton); |
||||
| 108 | array_push($buttonGroups, $transitionButtons); |
||||
| 109 | |||||
| 110 | if (WhichPortal::isHrPortal()) { |
||||
| 111 | array_push($buttonGroups, $unclaimButton); |
||||
| 112 | } |
||||
| 113 | |||||
| 114 | $data = [ |
||||
| 115 | // Localized strings. |
||||
| 116 | 'summary' => $summaryLang, |
||||
| 117 | 'menu' => $menuLang, |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 118 | 'job_status' => $status, |
||||
| 119 | 'job_status_description' => $status_description, |
||||
| 120 | 'is_claimed' => $jobIsClaimed, |
||||
| 121 | // User data. |
||||
| 122 | 'user' => $user, |
||||
| 123 | // HR Advisor data. |
||||
| 124 | 'hr_advisors' => $hr_advisors, |
||||
| 125 | // Job Poster data. |
||||
| 126 | 'job' => $jobPoster, |
||||
| 127 | // Application data. |
||||
| 128 | 'applications' => $applications, |
||||
| 129 | 'side_button_groups' => $buttonGroups, |
||||
| 130 | 'job_review_data' => $job_review_data, |
||||
| 131 | 'job_preview_data' => $job_preview_data, |
||||
| 132 | 'screening_plan_data' => $screening_plan_data, |
||||
| 133 | 'view_applicants_data' => $view_applicants_data, |
||||
| 134 | 'portal' => $portal, |
||||
| 135 | ]; |
||||
| 136 | |||||
| 137 | return view( |
||||
|
0 ignored issues
–
show
The function
view was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 138 | 'common/job_summary/job_summary', |
||||
| 139 | $data |
||||
| 140 | ); |
||||
| 141 | } |
||||
| 142 | |||||
| 143 | /** |
||||
| 144 | * Unclaim a Job Poster. |
||||
| 145 | * |
||||
| 146 | * @param \Illuminate\Http\Request $request Incoming request object. |
||||
| 147 | * @param \App\Models\JobPoster $job |
||||
| 148 | * @return \Illuminate\Http\Response |
||||
| 149 | */ |
||||
| 150 | public function unclaimJob(Request $request, JobPoster $job) |
||||
| 151 | { |
||||
| 152 | $hrAdvisor = $request->user()->hr_advisor; |
||||
| 153 | $hrAdvisor->claimed_jobs()->detach($job); |
||||
| 154 | |||||
| 155 | return redirect()->route('hr_advisor.jobs.index'); |
||||
|
0 ignored issues
–
show
The function
redirect was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 156 | } |
||||
| 157 | } |
||||
| 158 |