Passed
Push — task/comments-api ( c7d753...19d8e5 )
by Yonathan
32:15 queued 19:33
created

ClaimJobApiController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Http\Controllers\Api;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\HrAdvisor;
7
use App\Models\JobPoster;
8
use Illuminate\Http\Request;
9
10
class ClaimJobApiController extends Controller
11
{
12
    /**
13
     * Display a listing of the resource.
14
     *
15
     * @return \Illuminate\Http\Response
1 ignored issue
show
Coding Style introduced by
Function return type is not void, but function has no return statement
Loading history...
16
     */
17
    public function index()
18
    {
19
    }
20
21
    /**
1 ignored issue
show
Coding Style Documentation introduced by
Doc comment for parameter "$job" missing
Loading history...
22
     * Store a newly created resource in storage.
23
     *
24
     * @param  \Illuminate\Http\Request $request
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
25
     * @param  \App\Models\JobPoster  $jobPoster
2 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Doc comment for parameter $jobPoster does not match actual variable name $job
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
26
     * @return \Illuminate\Http\Response
27
     */
28
    public function store(Request $request, JobPoster $job)
29
    {
30
        $this->claimJob($request->user()->hr_advisor, $job);
31
32
        return response()->json(['status' => 'ok']);
33
    }
34
35
    /**
36
     * Display the specified resource.
37
     *
38
     * @param  \App\Models\HrAdvisor  $hrAdvisor
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
39
     * @return \Illuminate\Http\Response
1 ignored issue
show
Coding Style introduced by
Function return type is not void, but function has no return statement
Loading history...
40
     */
41
    public function show(HrAdvisor $hrAdvisor)
0 ignored issues
show
Unused Code introduced by
The parameter $hrAdvisor is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

41
    public function show(/** @scrutinizer ignore-unused */ HrAdvisor $hrAdvisor)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
    }
44
45
    /**
1 ignored issue
show
Coding Style Documentation introduced by
Doc comment for parameter "$job" missing
Loading history...
46
     * Update the specified resource in storage.
47
     *
48
     * @param  \Illuminate\Http\Request $request
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
49
     * @param  \App\Models\JobPoster  $jobPoster
2 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Doc comment for parameter $jobPoster does not match actual variable name $job
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
50
     * @return \Illuminate\Http\Response
1 ignored issue
show
Coding Style introduced by
Function return type is not void, but function has no return statement
Loading history...
51
     */
52
    public function update(Request $request, JobPoster $job)
0 ignored issues
show
Unused Code introduced by
The parameter $job is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function update(Request $request, /** @scrutinizer ignore-unused */ JobPoster $job)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function update(/** @scrutinizer ignore-unused */ Request $request, JobPoster $job)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
    }
55
56
    /**
1 ignored issue
show
Coding Style Documentation introduced by
Doc comment for parameter "$job" missing
Loading history...
57
     * Remove the specified resource from storage.
58
     *
59
     * @param  \Illuminate\Http\Request $request
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
60
     * @param  \App\Models\JobPoster  $jobPoster
2 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Doc comment for parameter $jobPoster does not match actual variable name $job
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
61
     * @return \Illuminate\Http\Response
62
     */
63
    public function destroy(Request $request, JobPoster $job)
64
    {
65
        $this->unclaimJob($request->user()->hr_advisor, $job);
66
67
        return response()->json(['status' => 'ok']);
68
    }
69
70
    /**
71
     * Claim a Job Poster.
72
     *
73
     * @param  \App\Models\HrAdvisor  $hrAdvisor
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
74
     * @param  \App\Models\JobPoster  $job
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
75
     * @return \Illuminate\Http\Response
1 ignored issue
show
Coding Style introduced by
Function return type is not void, but function has no return statement
Loading history...
76
     */
77
    public function claimJob(HrAdvisor $hrAdvisor, JobPoster $job)
78
    {
79
        $hrAdvisor->claimed_jobs()->attach($job);
80
    }
81
82
    /**
83
     * Unclaim a Job Poster.
84
     *
85
     * @param  \App\Models\HrAdvisor  $hrAdvisor
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
86
     * @param  \App\Models\JobPoster  $job
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
87
     * @return \Illuminate\Http\Response
1 ignored issue
show
Coding Style introduced by
Function return type is not void, but function has no return statement
Loading history...
88
     */
89
    public function unclaimJob(HrAdvisor $hrAdvisor, JobPoster $job)
90
    {
91
        $hrAdvisor->claimed_jobs()->detach($job);
92
    }
93
}
94