Added downstream(), and fixed failing tests in RoutingTest
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 42s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m48s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
2024-05-10 21:33:02 +10:00
parent edee0643ec
commit cd2efbd1d4
3 changed files with 52 additions and 15 deletions

View File

@@ -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.
*