Fix for address <-> children loops

This commit is contained in:
Deon George 2023-07-30 11:49:21 +10:00
parent df559b6b39
commit e28e17866e
1 changed files with 6 additions and 0 deletions

View File

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