Change System::match to return a single item regardless of role

This commit is contained in:
Deon George 2023-11-22 13:41:37 +11:00
parent 3221d7f679
commit 5b24ff944f

View File

@ -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 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) { ->where(function($item) use($o) {
return ($item->zone_id === $o->id) || ($item->zone->domain_id === $o->domain_id); 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;
} }
/** /**