From e28e17866e8df0c63b2cf9a66acbe3c119415008 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 30 Jul 2023 11:49:21 +1000 Subject: [PATCH] Fix for address <-> children loops --- app/Models/Address.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Models/Address.php b/app/Models/Address.php index 6874b7a..c3ca131 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -116,6 +116,8 @@ class Address extends Model case self::NODE_HC: // Identify our children. $children = self::select('addresses.*') + ->where('zone_id',$this->zone_id) + ->where('region_id',$this->region_id) ->where('hub_id',$this->id); break; @@ -136,6 +138,10 @@ class Address extends Model ->where('zone_id',$this->zone_id); } + // I cant have myself as a child, and have a high role than me + $children->where('id','<>',$this->id) + ->where('role','>',$this->role); + // Remove any children that we have session details for (SAME AS HC) $sessions = self::select('hubnodes.*') ->join('system_zone',['system_zone.system_id'=>'addresses.system_id','system_zone.zone_id'=>'addresses.zone_id'])