forked from dbarzin/mercator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhysicalLink.php
171 lines (136 loc) · 3.95 KB
/
PhysicalLink.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
namespace App;
use App\Peripheral;
use App\Phone;
use App\PhysicalRouter;
use App\PhysicalSecurityDevice;
use App\PhysicalServer;
use App\PhysicalSwitch;
use App\StorageDevice;
use App\WifiTerminal;
use App\Workstation;
use App\Traits\Auditable;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class PhysicalLink extends Model
{
use SoftDeletes, Auditable;
public $table = 'physical_links';
public static $searchable = [
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at',
];
protected $fillable = [
'src_port',
'dest_port',
'created_at',
'updated_at',
'deleted_at',
];
// Sources
public function peripheralSrc()
{
return $this->belongsTo(Peripheral::class, 'peripheral_src_id');
}
public function phoneSrc()
{
return $this->belongsTo(Phone::class, 'phone_src_id');
}
public function physicalRouterSrc()
{
return $this->belongsTo(PhysicalRouter::class, 'physical_router_src_id');
}
public function physicalSecurityDeviceSrc()
{
return $this->belongsTo(PhysicalSecurityDevice::class, 'physical_security_device_src_id');
}
public function physicalServerSrc()
{
return $this->belongsTo(PhysicalServer::class, 'physical_server_src_id');
}
public function physicalSwitchSrc()
{
return $this->belongsTo(PhysicalSwitch::class, 'physical_switch_src_id');
}
public function storageDeviceSrc()
{
return $this->belongsTo(StorageDevice::class, 'storage_device_src_id');
}
public function wifiTerminalSrc()
{
return $this->belongsTo(WifiTerminal::class, 'wifi_terminal_src_id');
}
public function workstationSrc()
{
return $this->belongsTo(Workstation::class, 'workstation_src_id');
}
public function routerSrc()
{
return $this->belongsTo(Router::class, 'router_src_id');
}
public function networkSwitchSrc()
{
return $this->belongsTo(NetworkSwitch::class, 'network_switch_src_id');
}
public function logicalServerSrc()
{
return $this->belongsTo(LogicalServer::class, 'logical_server_src_id');
}
// Destinations
public function peripheralDest()
{
return $this->belongsTo(Peripheral::class, 'peripheral_dest_id');
}
public function phoneDest()
{
return $this->belongsTo(Phone::class, 'phone_dest_id');
}
public function physicalRouterDest()
{
return $this->belongsTo(PhysicalRouter::class, 'physical_router_dest_id');
}
public function physicalSecurityDeviceDest()
{
return $this->belongsTo(PhysicalSecurityDevice::class, 'physical_security_device_dest_id');
}
public function physicalServerDest()
{
return $this->belongsTo(PhysicalServer::class, 'physical_server_dest_id');
}
public function physicalSwitchDest()
{
return $this->belongsTo(PhysicalSwitch::class, 'physical_switch_dest_id');
}
public function storageDeviceDest()
{
return $this->belongsTo(StorageDevice::class, 'storage_device_dest_id');
}
public function wifiTerminalDest()
{
return $this->belongsTo(WifiTerminal::class, 'wifi_terminal_dest_id');
}
public function workstationDest()
{
return $this->belongsTo(Workstation::class, 'workstation_dest_id');
}
public function routerDest()
{
return $this->belongsTo(Router::class, 'router_dest_id');
}
public function networkSwitchDest()
{
return $this->belongsTo(NetworkSwitch::class, 'network_switch_dest_id');
}
public function logicalServerDest()
{
return $this->belongsTo(LogicalServer::class, 'logical_server_dest_id');
}
protected function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
}