Added downstream(), and fixed failing tests in RoutingTest
This commit is contained in:
@@ -24,6 +24,7 @@ class AddressCheck extends Command
|
||||
|
||||
$this->info(sprintf('Address: %s (%s)',$o->ftn,$o->role_name));
|
||||
$this->info(sprintf("Children: \n- %s",$o->children()->pluck('ftn4d')->join("\n- ")));
|
||||
$this->info(sprintf("Downstream: \n- %s",$o->downstream()->pluck('ftn4d')->join("\n- ")));
|
||||
$this->info(sprintf('Uplink: %s (Parent: %s)',$o->uplink()?->ftn,$o->parent()?->ftn));
|
||||
$this->info(sprintf('Our Address: %s',our_address($o)?->ftn));
|
||||
$this->info(sprintf('- Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(',')));
|
||||
|
@@ -873,6 +873,19 @@ class Address extends Model
|
||||
return $children->filter(function($item) use ($exclude) { return ! $exclude->pluck('id')->contains($item->id);});
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all our nodes and their children
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function downstream(): \Illuminate\Support\Collection
|
||||
{
|
||||
return $this->downlinks()->transform(function($item) {
|
||||
return $item->nodes()->push($item);
|
||||
})->flatten();
|
||||
}
|
||||
|
||||
/**
|
||||
* Files waiting to be sent to this system
|
||||
*
|
||||
@@ -1149,6 +1162,29 @@ class Address extends Model
|
||||
return Netmail::whereIn('id',$netmails->pluck('id'))->get();
|
||||
}
|
||||
|
||||
public function nodes(): Collection
|
||||
{
|
||||
switch ($this->role_id) {
|
||||
case self::NODE_NN:
|
||||
return $this->nodes_point;
|
||||
|
||||
case self::NODE_HC:
|
||||
return $this->nodes_hub;
|
||||
|
||||
case self::NODE_NC:
|
||||
return $this->nodes_net;
|
||||
|
||||
case self::NODE_RC:
|
||||
return $this->nodes_region;
|
||||
|
||||
case self::NODE_ZC:
|
||||
return $this->nodes_zone;
|
||||
|
||||
default:
|
||||
return new Collection;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the immediate parent for this node.
|
||||
*
|
||||
|
Reference in New Issue
Block a user