diff --git a/app/Classes/Node.php b/app/Classes/Node.php index 7829fb7..18a5a24 100644 --- a/app/Classes/Node.php +++ b/app/Classes/Node.php @@ -133,7 +133,7 @@ class Node // Ignore any duplicate FTNs that we get if ($this->ftns->search(function($item) use ($value) { return $item->id === $value->id; }) !== FALSE) { - Log::debug(sprintf('%s: - Ignoring Duplicate FTN [%s]',__METHOD__,$value->ftn)); + Log::debug(sprintf('%s:- Ignoring Duplicate FTN [%s]',self::LOGKEY,$value->ftn)); break; } @@ -144,7 +144,7 @@ class Node case 'ftn_other': // Ignore any duplicate FTNs that we get if ($this->ftns_other->search($value) !== FALSE) { - Log::debug(sprintf('%s: - Ignoring Duplicate FTN [%s]',__METHOD__,$value)); + Log::debug(sprintf('%s:- Ignoring Duplicate FTN [%s]',self::LOGKEY,$value)); break; } diff --git a/app/Models/Address.php b/app/Models/Address.php index 44e0a5c..0bc26a6 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -419,7 +419,7 @@ class Address extends Model return $o; } - $o = (new self) + $o = ($x=(new self) ->select('addresses.*') ->join('zones',['zones.id'=>'addresses.zone_id']) ->join('domains',['domains.id'=>'zones.domain_id']) @@ -447,7 +447,7 @@ class Address extends Model }) ->when((! $ftn['d']),function($query) { $query->where('zones.default',TRUE); - }) + })) ->single(); if ($create) { @@ -500,8 +500,14 @@ class Address extends Model $o->host_id = $ftn['n']; $o->node_id = $ftn['f']; $o->point_id = $ftn['p']; - $o->role = self::NODE_UNKNOWN; - $so->addresses()->save($o); + $o->role = $ftn['p'] ? self::NODE_POINT : self::NODE_UNKNOWN; + + try { + $so->addresses()->save($o); + } catch (\Exception $e) { + Log::error(sprintf('%s:! ERROR creating address [%s] (%s)',self::LOGKEY,$x->toSql(),get_class($e)),['bindings'=>$x->getBindings()]); + return NULL; + } } return ($o && $o->system->active) ? $o : NULL;