1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Axsor\PhpIPAM\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use Axsor\PhpIPAM\Http\Requests\DeviceRequest; |
6
|
|
|
use Axsor\PhpIPAM\Models\Address; |
7
|
|
|
use Axsor\PhpIPAM\Models\Device; |
8
|
|
|
use Axsor\PhpIPAM\Models\Subnet; |
9
|
|
|
|
10
|
|
|
class DeviceController |
11
|
|
|
{ |
12
|
|
|
protected $request; |
13
|
|
|
|
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
$this->request = new DeviceRequest; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function index() |
20
|
|
|
{ |
21
|
|
|
$response = $this->request->index(); |
22
|
|
|
|
23
|
|
|
return response_to_collect($response, Device::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function show($device) |
27
|
|
|
{ |
28
|
|
|
$response = $this->request->show($device); |
29
|
|
|
|
30
|
|
|
return new Device($response['data']); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function types($device) |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
$response = $this->request->types(); |
|
|
|
|
36
|
|
|
|
37
|
|
|
return response_to_collect($response, Device::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function subnets($device) |
41
|
|
|
{ |
42
|
|
|
$response = $this->request->subnets($device); |
43
|
|
|
|
44
|
|
|
return response_to_collect($response, Subnet::class); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function addresses($device) |
48
|
|
|
{ |
49
|
|
|
$response = $this->request->addresses($device); |
50
|
|
|
|
51
|
|
|
return response_to_collect($response, Address::class); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function create(array $device) |
55
|
|
|
{ |
56
|
|
|
$response = $this->request->create($device); |
57
|
|
|
|
58
|
|
|
return get_key_or_null($response, 'id'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function update($device, array $newData) |
62
|
|
|
{ |
63
|
|
|
$response = $this->request->update($device, $newData); |
64
|
|
|
|
65
|
|
|
return (bool) $response['success']; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function drop($device) |
69
|
|
|
{ |
70
|
|
|
$response = $this->request->drop($device); |
71
|
|
|
|
72
|
|
|
return (bool) $response['success']; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.