Added downstream(), and fixed failing tests in RoutingTest
This commit is contained in:
@@ -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