diff --git a/app/Models/Address.php b/app/Models/Address.php index ac02c9c..00c46fe 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -13,6 +13,15 @@ use App\Classes\FTN\Packet; use App\Http\Controllers\DomainController; use App\Traits\{ScopeActive,UsePostgres}; +/** + * @todo Need to stop this from happening: + * In this example nn:3/1 can be defined 3 different ways. + * + id | zone_id | region_id | host_id | node_id | point_id | status | role | system_id | hub_id + * + ----+---------+-----------+---------+---------+----------+--------+------+-----------+-------- + * + 533 | 6 | 3 | 0 | 1 | 0 | | 4 | 1 | + * + 534 | 6 | 3 | 3 | 1 | 0 | | 2 | 1 | + * + 535 | 6 | 0 | 3 | 1 | 0 | | 2 | 1 | + */ class Address extends Model { use ScopeActive,SoftDeletes,UsePostgres; @@ -184,6 +193,7 @@ class Address extends Model case DomainController::NODE_UNKNOWN: case DomainController::NODE_POINT: + case DomainController::NODE_DOWN: // @todo Points - if the boss is defined, we should return it. return NULL; @@ -298,7 +308,18 @@ class Address extends Model $o = (new self)->active() ->select('addresses.*') ->where('zones.zone_id',$ftn['z']) - ->where('host_id',$ftn['n']) + ->where(function($q) use ($ftn) { + return $q->where(function($qq) use ($ftn) { + return $qq + ->where('region_id',0) + ->where('host_id',$ftn['n']); + }) + ->orWhere(function($qq) use ($ftn) { + return $qq + ->where('region_id',$ftn['n']) + ->where('host_id',0); + }); + }) ->where('node_id',$ftn['f']) ->where('point_id',$ftn['p']) ->join('zones',['zones.id'=>'addresses.zone_id']) diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index de2d086..64dbc32 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -15,7 +15,7 @@ use App\Http\Controllers\DomainController as DC; @endif @if($o->zcs->count()) -

This system is the ZC for the following zones: {!! $o->zcs->map(function($item) { return sprintf('%d@%s',$item->zone_id,$item->domain->name); })->join(', ') !!}

+

This system is the ZC for the following zones: {!! $o->zcs->sortBy('zone_id')->map(function($item) { return sprintf('%d@%s',$item->zone_id,$item->domain->name); })->join(', ') !!}

@endif