Completed
Push — dev ( 0b98cc...75be95 )
by Chris
22s queued 10s
created

ManagerApiController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Controllers\Api;
4
5
use App\Models\Manager;
6
use Illuminate\Http\Request;
7
use App\Http\Controllers\Controller;
8
use App\Http\Requests\UpdateManager;
9
use Illuminate\Support\Facades\Auth;
10
11
class ManagerApiController extends Controller
12
{
13
    /**
14
     * Class constructor.
15 5
     */
16
    public function __construct()
17
    {
18 5
        // This applies the appropriate policy to each resource route.
19 5
        $this->authorizeResource(Manager::class, 'manager');
20
    }
21
22
    /**
23
     * Display a listing of the resource.
24
     *
25
     * @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...
26
     */
27
    public function index()
28
    {
29
        // TODO: complete.
30
    }
31
32
    /**
33
     * Store a newly created resource in storage.
34
     *
35
     * @param  \Illuminate\Http\Request $request Incoming Request.
36
     * @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...
37
     */
38
    public function store(Request $request)
0 ignored issues
show
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

38
    public function store(/** @scrutinizer ignore-unused */ Request $request)

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...
39
    {
40
        // TODO: complete.
41
    }
42
43
    /**
44
     * Display the specified resource.
45
     *
46
     * @param  \App\Models\Manager $manager Incoming Manager.
47
     * @return \Illuminate\Http\Response
48 1
     */
49
    public function show(Manager $manager)
50 1
    {
51
        return response()->json($manager->toApiArray());
52
    }
53
54
    /**
55
     * Display the Manager for the current logged in user.
56
     *
57
     * @return \Illuminate\Http\Response
58
     */
59
    public function showAuthenticated()
60 1
    {
61
        $user = Auth::user();
62 1
        if ($user !== null && $user->manager !== null) {
0 ignored issues
show
Bug introduced by
Accessing manager on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
63 1
            return response()->json($user->manager->toApiArray());
64 1
        }
65 1
        return response()->json([]);
66
    }
67
68
    /**
69
     * Update the specified resource in storage.
70
     *
71
     * @param  \App\Http\Requests\UpdateManager $request Incoming Form Request.
72
     * @param  \App\Models\Manager              $manager Incoming Manager.
73
     * @return \Illuminate\Http\Response
74
     */
75
    public function update(UpdateManager $request, Manager $manager)
76
    {
77
        $request->validated();
78
        $manager->fill($request->input());
79
        $manager->save();
80
        return response()->json($manager->toApiArray());
81
    }
82
83
    /**
84
     * Remove the specified resource from storage.
85
     *
86
     * @param  \App\Models\Manager $manager Incoming Manager.
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 destroy(Manager $manager)
0 ignored issues
show
Unused Code introduced by
The parameter $manager 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

89
    public function destroy(/** @scrutinizer ignore-unused */ Manager $manager)

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...
90
    {
91
        // TODO: complete.
92
    }
93
}
94