|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* app/Models/General/IPv4.php |
|
4
|
|
|
* |
|
5
|
|
|
* Model for IPv4 Search |
|
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\Models\General; |
|
27
|
|
|
|
|
28
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* App\Models\General\IPv4 |
|
32
|
|
|
* |
|
33
|
|
|
* @property integer $ipv4_address_id |
|
34
|
|
|
* @property string $ipv4_address |
|
35
|
|
|
* @property integer $ipv4_prefixlen |
|
36
|
|
|
* @property string $ipv4_network_id |
|
37
|
|
|
* @property integer $port_id |
|
38
|
|
|
* @property string $context_name |
|
39
|
|
|
* @property-read \App\Models\Port $port |
|
40
|
|
|
* @property-read \App\Models\Device $device |
|
41
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4AddressId($value) |
|
42
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4Address($value) |
|
43
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4Prefixlen($value) |
|
44
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereIpv4NetworkId($value) |
|
45
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 wherePortId($value) |
|
46
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\General\IPv4 whereContextName($value) |
|
47
|
|
|
* @mixin \Eloquent |
|
48
|
|
|
*/ |
|
49
|
|
|
class IPv4 extends Model |
|
50
|
|
|
{ |
|
51
|
|
|
|
|
52
|
|
|
protected $hidden = ['ip']; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Indicates if the model should be timestamped. |
|
56
|
|
|
* |
|
57
|
|
|
* @var bool |
|
58
|
|
|
*/ |
|
59
|
|
|
public $timestamps = false; |
|
60
|
|
|
/** |
|
61
|
|
|
* The table associated with the model. |
|
62
|
|
|
* |
|
63
|
|
|
* @var string |
|
64
|
|
|
*/ |
|
65
|
|
|
protected $table = 'ipv4_addresses'; |
|
66
|
|
|
/** |
|
67
|
|
|
* The primary key column name. |
|
68
|
|
|
* |
|
69
|
|
|
* @var string |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $primaryKey = 'ipv4_address_id'; |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
// ---- Accessors/Mutators ---- |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
// ---- Define Relationships ---- |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns the port this entry belongs to. |
|
81
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
82
|
|
|
*/ |
|
83
|
|
|
public function port() |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->belongsTo('App\Models\Port', 'port_id', 'port_id'); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Returns the device this entry belongs to. |
|
90
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
|
91
|
|
|
*/ |
|
92
|
|
|
public function device() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->belongsTo('App\Models\Device', 'device_id', 'device_id'); |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|