SearchController::ipv6()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * app/Api/Controllers/General/SearchController.php
4
 *
5
 * API Controller for resources such as IP, ARP, Mac, etc
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Neil Lathwood
23
 * @author     Neil Lathwood <[email protected]>
24
 */
25
26
namespace App\Api\Controllers\General;
27
28
use App\Api\Controllers\Controller;
29
use App\Models\General\IPv4;
30
use App\Models\General\IPv4Mac;
31
use App\Models\General\IPv6;
32
use App\Models\Port;
33
use Dingo\Api\Routing\Helpers;
34
use Illuminate\Http\Request;
35
36
class SearchController extends Controller
37
{
38
39
    use Helpers;
40
41
    /**
42
     * Display a listing of all alerts
43
     *
44
     * @param  \Illuminate\Http\Request  $request
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function index(Request $request)
48
    {
49
        return $this->response->array(array('statusText' => 'OK', 'resources' => ['ipv4', 'ipv6', 'arp', 'mac']));
50
    }
51
52
53
    /**
54
     * Show the form for creating a new resource.
55
     *
56
     * @return \Illuminate\Http\Response|null
57
     */
58
    public function create()
59
    {
60
        //
61
    }
62
63
    /**
64
     * Store a newly created resource in storage.
65
     *
66
     * @param  \Illuminate\Http\Request  $request
67
     * @return \Illuminate\Http\Response|null
68
     */
69
    public function store(Request $request)
70
    {
71
        //
72
    }
73
74
    /**
75
     * Display the specified resource.
76
     *
77
     * @return \Illuminate\Http\Response|null
78
     */
79
    public function show()
80
    {
81
        //
82
    }
83
84
    /**
85
     * Show the form for editing the specified resource.
86
     *
87
     * @param  int  $id
88
     * @return \Illuminate\Http\Response|null
89
     */
90
    public function edit($id)
91
    {
92
        //
93
    }
94
95
    /**
96
     * Update the specified resource in storage.
97
     *
98
     * @param  \Illuminate\Http\Request  $request
99
     * @param  int  $id
100
     * @return \Illuminate\Http\Response|null
101
     */
102
    public function update(Request $request, $id)
103
    {
104
        //
105
    }
106
107
    /**
108
     * Remove the specified resource from storage.
109
     *
110
     * @param  int  $id
111
     * @return \Illuminate\Http\Response|null
112
     */
113
    public function destroy($id)
114
    {
115
        //
116
    }
117
118
    /**
119
     * Display the specified resource.
120
     *
121
     * @param  \Illuminate\Http\Request  $request
122
     * @return \Illuminate\Pagination\LengthAwarePaginator
123
     */
124 1
    public function ipv4(Request $request)
125
    {
126 1
        $per_page = $request->per_page ?: 25;
127 1
        return IPv4::paginate($per_page);
128
    }
129
130
    /**
131
     * Display the specified resource.
132
     *
133
     * @param  \Illuminate\Http\Request  $request
134
     * @return \Illuminate\Pagination\LengthAwarePaginator
135
     */
136 1
    public function ipv6(Request $request)
137
    {
138 1
        $per_page = $request->per_page ?: 25;
139 1
        return IPv6::paginate($per_page);
140
    }
141
142
    /**
143
     * Display the specified resource.
144
     *
145
     * @param  \Illuminate\Http\Request  $request
146
     * @return \Illuminate\Pagination\LengthAwarePaginator
147
     */
148 1
    public function mac(Request $request)
149
    {
150 1
        $per_page = $request->per_page ?: 25;
151 1
        return Port::select('port_id', 'ifPhysAddress')->paginate($per_page);
152
    }
153
154
    /**
155
     * Display the specified resource.
156
     *
157
     * @param  \Illuminate\Http\Request  $request
158
     * @return \Illuminate\Pagination\LengthAwarePaginator
159
     */
160 1
    public function arp(Request $request)
161
    {
162 1
        $per_page = $request->per_page ?: 25;
163 1
        return IPv4Mac::paginate($per_page);
164
    }
165
}
166