Skip to content

Commit

Permalink
When adding a new device, parse hostname, sysName and dns_hostname to…
Browse files Browse the repository at this point in the history
… make sure we only store the name, not the fqdn.
  • Loading branch information
mark-unwin committed Feb 9, 2024
1 parent 244565b commit 1b55cbc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Models/DevicesModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,22 @@ public function create($data = null): ?int
if (empty($data->name)) {
if (!empty($data->hostname)) {
$data->name = strtolower($data->hostname);
if (strpos($data->hostname, '.') !== false) {
$temp = explode('.', $data->hostname);
$data->name = $temp[0];
}
} else if (!empty($data->sysName)) {
$data->name = strtolower($data->sysName);
if (strpos($data->sysName, '.') !== false) {
$temp = explode('.', $data->sysName);
$data->name = $temp[0];
}
} else if (!empty($data->dns_hostname)) {
$data->name = strtolower($data->dns_hostname);
if (strpos($data->dns_hostname, '.') !== false) {
$temp = explode('.', $data->dns_hostname);
$data->name = $temp[0];
}
} else if (!empty($data->ip)) {
$data->name = ip_address_from_db($data->ip);
} else {
Expand Down

0 comments on commit 1b55cbc

Please sign in to comment.