Completed
Push — notifications ( 4f3de2...5ee32e )
by Tony
19s
created

DeviceController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Settings;
6
use Dingo\Api\Http;
7
use Dingo\Api\Routing\Helpers;
8
use Illuminate\Http\Request;
9
10
class DeviceController extends Controller
11
{
12
    use Helpers;
13
14
    /**
15
     * Constructor
16
     */
17 2
    public function __construct(Request $request) {
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

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

Loading history...
18 2
        $this->middleware('auth');
19 2
    }
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
25
     */
26 2
    public function index(Request $request)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

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

Loading history...
27
    {
28 2
        $devices = $this->api->be(auth()->user())->get('/api/devices');
0 ignored issues
show
Bug introduced by
The method user() does not seem to exist on object<Illuminate\Contracts\Auth\Factory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29 2
        return view('devices.list', ['devices'=>$devices]);
30
    }
31
32
    /**
33
     * Show the form for creating a new resource.
34
     *
35
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
36
     */
37
    public function create()
38
    {
39
        // add new device form
40
        return view('devices.create');
41
    }
42
43
    /**
44
     * Store a newly created resource in storage.
45
     *
46
     * @param  \Illuminate\Http\Request  $request
47
     * @return \Illuminate\Http\RedirectResponse
48
     */
49
    public function store(Request $request)
50
    {
51
        // save device
52
53
        $this->validate($request, [
54
            'hostname'        => 'required|unique:devices|max:128',
55
            'snmpver'         => 'required|alpha_num|max:4',
56
            'transport'       => 'required|alpha_num|max:16',
57
            'port_assoc_mode' => 'required|alpha',
58
            'community'       => 'required_if:snmpver,v1,v2c|max:255',
59
            'authlevel'       => 'required_if:snmpver,v3|alpha|max:15',
60
            'authname'        => 'required_if:authlevel,authNoPriv|max:64',
61
            'authalgo'        => 'required_if:authlevel,authNoPriv|in:MD5,SHA|max:3',
62
            'cryptopass'      => 'required_if:authlevel,authPriv|max:64',
63
            'cryptoalgo'      => 'required_if:authlevel,authPriv|in:AES,DES|max:3',
64
        ]);
65
        return redirect()->route('devices.index');
66
    }
67
68
    /**
69
     * Display the specified resource.
70
     *
71
     * @param  int  $id
72
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
73
     */
74
    public function show($id)
1 ignored issue
show
Unused Code introduced by
The parameter $id is not used and could be removed.

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

Loading history...
75
    {
76
        // show a single device
77
    }
78
79
    /**
80
     * Show the form for editing the specified resource.
81
     *
82
     * @param  int  $id
83
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
84
     */
85
    public function edit($id)
1 ignored issue
show
Unused Code introduced by
The parameter $id is not used and could be removed.

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

Loading history...
86
    {
87
        //edit device form??
88
    }
89
90
    /**
91
     * Update the specified resource in storage.
92
     *
93
     * @param  \Illuminate\Http\Request  $request
94
     * @param  int  $id
95
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
96
     */
97
    public function update(Request $request, $id)
2 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from 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 $id is not used and could be removed.

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

Loading history...
98
    {
99
        //process device modify
100
    }
101
102
    /**
103
     * Remove the specified resource from storage.
104
     *
105
     * @param  int  $id
106
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\Response|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
107
     */
108
    public function destroy($id)
1 ignored issue
show
Unused Code introduced by
The parameter $id is not used and could be removed.

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

Loading history...
109
    {
110
        // delete device
111
    }
112
}
113