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'])