Completed
Push — devices ( 4afcb8 )
by Arthur
02:56
created

DeviceController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace BB\Http\Controllers;
4
5
use BB\Entities\ACSNode;
6
use BB\Http\Requests;
7
8
class DeviceController extends Controller
9
{
10
11
    /**
12
     * Display a listing of the resource.
13
     *
14
     * @return Response
15
     */
16
    public function index()
17
    {
18
        $devices = ACSNode::all();
19
20
        return view('devices.index', ['devices' => $devices]);
21
    }
22
23
    public function create()
24
    {
25
        return view('devices.create');
26
    }
27
28
    public function store()
29
    {
30
        $data = \Request::only([
31
            'name', 'device_id', 'api_key'
32
        ]);
33
34
        ACSNode::create($data);
35
36
        return \Redirect::route('devices.index');
37
    }
38
39
    /**
40
     * Display the specified resource.
41
     *
42
     * @param  int  $id
43
     * @return Response
44
     */
45
    public function show($id)
46
    {
47
        //
48
    }
49
50
    /**
51
     * Show the form for editing the specified resource.
52
     *
53
     * @param  int  $id
54
     * @return Response
55
     */
56
    public function edit($id)
57
    {
58
        //
59
    }
60
61
    /**
62
     * Update the specified resource in storage.
63
     *
64
     * @param  int  $id
65
     * @return Response
66
     */
67
    public function update($id)
68
    {
69
        //
70
    }
71
72
    /**
73
     * Remove the specified resource from storage.
74
     *
75
     * @param  int  $id
76
     * @return Response
77
     */
78
    public function destroy($id)
79
    {
80
        $device = ACSNode::findOrFail($id);
81
        $device->delete();
82
83
        return \Redirect::route('devices.index');
84
    }
85
}
86