Passed
Push — dependabot/npm_and_yarn/dev/st... ( 917c39...79f3f4 )
by
unknown
12:32 queued 07:14
created

JobSummaryController::show()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 43
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 43
rs 9.504
cc 2
nc 2
nop 2
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\JobPoster;
7
use App\Models\HrAdvisor;
8
use Illuminate\Http\Request;
9
use Illuminate\Support\Facades\Auth;
10
use Illuminate\Support\Facades\Lang;
11
12
class JobSummaryController extends Controller
13
{
14
    /**
15
     * Display the specified job summary.
16
     *
17
     * @param  \Illuminate\Http\Request $request Incoming request object.
18
     * @param  \App\Models\JobPoster $job Job Poster object.
19
     * @return \Illuminate\Http\Response
20
     */
21
    public function show(Request $request, JobPoster $job)
22
    {
23
        $user = Auth::user();
24
25
        $applications = $job->submitted_applications;
26
        $advisor = $user->hr_advisor;
27
        $jobIsClaimed = ($advisor !== null) &&
28
            $advisor->claimed_job_ids->contains($job->id);
29
30
        $summaryLang = Lang::get('hr_advisor/job_summary');
31
32
        $view_applicants_data = [
33
            'imgSrc' => '/images/job-process-summary-tool-applicants.svg',
34
            'imgAlt' => "{$summaryLang['view_applicants_icon']} {$summaryLang['flat_icons']}",
35
            'text' => $summaryLang['view_applicants_button'],
36
            'url' => route('hr_advisor.jobs.applications', $job),
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

36
            'url' => /** @scrutinizer ignore-call */ route('hr_advisor.jobs.applications', $job),
Loading history...
37
            'disabled' => $job->isClosed(),
38
        ];
39
40
        $data = [
41
            // Localized strings.
42
            'summary' => $summaryLang,
43
            'is_claimed' => $jobIsClaimed,
44
            // User data.
45
            'user' => $user,
46
            // Job Poster data.
47
            'job' => $job,
48
            // Application data.
49
            'applications' => $applications,
50
            // TODO: Add Routes.
51
            // 'send_manager' => ,
52
            // 'send_translation' => ,
53
            // 'approve_publishing' => ,
54
            'job_review_url' => route('hr_advisor.jobs.review', $job),
55
            'job_preview_url' => '/',
56
            'screening_plan_url' => '/',
57
            'view_applicants_data' => $view_applicants_data,
58
            'relinquish_job' => route('hr_advisor.jobs.unclaim', $job),
59
        ];
60
61
        return view(
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

61
        return /** @scrutinizer ignore-call */ view(
Loading history...
62
            'hr_advisor/job_summary',
63
            $data
64
        );
65
    }
66
67
    /**
68
     * Unclaim a Job Poster.
69
     *
70
     * @param  \Illuminate\Http\Request $request Incoming request object.
71
     * @param  \App\Models\JobPoster  $job
72
     * @return \Illuminate\Http\Response
73
     */
74
    public function unclaimJob(Request $request, JobPoster $job)
75
    {
76
        $hrAdvisor = $request->user()->hr_advisor;
77
        $hrAdvisor->claimed_jobs()->detach($job);
78
79
        return redirect()->route('hr_advisor.jobs.index');
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

79
        return /** @scrutinizer ignore-call */ redirect()->route('hr_advisor.jobs.index');
Loading history...
80
    }
81
}
82