From 5b24ff944fbe20a495597c6c2d31b95c0a93ac90 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 22 Nov 2023 13:41:37 +1100 Subject: [PATCH] Change System::match to return a single item regardless of role --- app/Models/System.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/Models/System.php b/app/Models/System.php index 2a403c5..e2b5888 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -213,13 +213,16 @@ class System extends Model */ public function match(Zone $o,int $type=(Address::NODE_HC|Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_POINT)): Collection { - return $this->akas + $akas = $this->akas ->where(function($item) use($o) { return ($item->zone_id === $o->id) || ($item->zone->domain_id === $o->domain_id); - }) - ->filter(function($item) use ($type) { - return $item->role & $type; }); + + return ($akas->count() > 1) + ? $akas->filter(function($item) use ($type) { + return $item->role & $type; + }) + : $akas; } /**