Passed
Push — feature/application-access-hr ( e2b27f...7cec62 )
by Yonathan
05:47 queued 10s
created

JobSummaryController::show()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 33
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 33
rs 9.6333
c 0
b 0
f 0
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
        $data = [
31
            // Localized strings.
32
            'summary' => Lang::get('hr_advisor/job_summary'),
33
            'is_claimed' => $jobIsClaimed,
34
            // User data.
35
            'user' => $user,
36
            // Job Poster data.
37
            'job' => $job,
38
            // Application data.
39
            'applications' => $applications,
40
            // TODO: Add Routes.
41
            // 'send_manager' => ,
42
            // 'send_translation' => ,
43
            // 'approve_publishing' => ,
44
            'job_review_url' => route('hr_advisor.jobs.review', $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

44
            'job_review_url' => /** @scrutinizer ignore-call */ route('hr_advisor.jobs.review', $job),
Loading history...
45
            'job_preview_url' => '/',
46
            'screening_plan_url' => '/',
47
            'view_applicants_url' => '/',
48
            'relinquish_job' => route('hr_advisor.jobs.unclaim', $job),
49
        ];
50
51
        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

51
        return /** @scrutinizer ignore-call */ view(
Loading history...
52
            'hr_advisor/job_summary',
53
            $data
54
        );
55
    }
56
57
    /**
58
     * Unclaim a Job Poster.
59
     *
60
     * @param  \Illuminate\Http\Request $request Incoming request object.
61
     * @param  \App\Models\JobPoster  $job
62
     * @return \Illuminate\Http\Response
63
     */
64
    public function unclaimJob(Request $request, JobPoster $job)
65
    {
66
        $hrAdvisor = $request->user()->hr_advisor;
67
        $hrAdvisor->claimed_jobs()->detach($job);
68
69
        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

69
        return /** @scrutinizer ignore-call */ redirect()->route('hr_advisor.jobs.index');
Loading history...
70
    }
71
}
72