Completed
Branch develop (0d51b0)
by Tony
03:46
created

DeviceController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 2
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\DataTables\DeviceDataTable;
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
     * Display a listing of the resource.
16
     *
17 2
     * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View
18 2
     */
19 2
    public function index(DeviceDataTable $dataTable)
20
    {
21
        return $dataTable->render('devices.list');
22
    }
23
24
    /**
25
     * Show the form for creating a new resource.
26 2
     *
27
     * @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...
28 2
     */
29 2
    public function create()
30
    {
31
        // add new device form
32
        return view('devices.create');
33
    }
34
35
    /**
36
     * Store a newly created resource in storage.
37
     *
38
     * @param  \Illuminate\Http\Request  $request
39
     * @return \Illuminate\Http\RedirectResponse
40
     */
41
    public function store(Request $request)
42
    {
43
        // save device
44
45
        $this->validate($request, [
46
            'hostname'        => 'required|unique:devices|max:128',
47
            'snmpver'         => 'required|alpha_num|max:4',
48
            'transport'       => 'required|alpha_num|max:16',
49
            'port_assoc_mode' => 'required|alpha',
50
            'community'       => 'required_if:snmpver,v1,v2c|max:255',
51
            'authlevel'       => 'required_if:snmpver,v3|alpha|max:15',
52
            'authname'        => 'required_if:authlevel,authNoPriv|max:64',
53
            'authalgo'        => 'required_if:authlevel,authNoPriv|in:MD5,SHA|max:3',
54
            'cryptopass'      => 'required_if:authlevel,authPriv|max:64',
55
            'cryptoalgo'      => 'required_if:authlevel,authPriv|in:AES,DES|max:3',
56
        ]);
57
        return redirect()->route('devices.index');
58
    }
59
60
    /**
61
     * Display the specified resource.
62
     *
63
     * @param  int  $id
64
     * @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...
65
     */
66
    public function show($id)
67
    {
68
        // show a single device
69
    }
70
71
    /**
72
     * Show the form for editing the specified resource.
73
     *
74
     * @param  int  $id
75
     * @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...
76
     */
77
    public function edit($id)
78
    {
79
        //edit device form??
80
    }
81
82
    /**
83
     * Update the specified resource in storage.
84
     *
85
     * @param  \Illuminate\Http\Request  $request
86
     * @param  int  $id
87
     * @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...
88
     */
89
    public function update(Request $request, $id)
90
    {
91
        //process device modify
92
    }
93
94
    /**
95
     * Remove the specified resource from storage.
96
     *
97
     * @param  int  $id
98
     * @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...
99
     */
100
    public function destroy($id)
101
    {
102
        // delete device
103
    }
104
}
105