Minor optimisations when editing and viewing domains

This commit is contained in:
2024-11-05 00:28:34 +11:00
parent dc2e84386f
commit 60ea0afc98
6 changed files with 91 additions and 73 deletions

View File

@@ -115,9 +115,10 @@ class System extends Model
public function sessions()
{
return $this->belongsToMany(Zone::class)
->select(['id','zones.zone_id','domain_id','active'])
->select(['zones.id','zones.zone_id','domain_id','zones.active'])
->join('domains',['domains.id'=>'zones.domain_id'])
->withPivot(['sespass','pktpass','ticpass','fixpass','zt_ipv4','zt_ipv6','default'])
->dontCache();
->orderBy('domains.name');
}
/**
@@ -301,6 +302,13 @@ class System extends Model
}
}
public function inDomain(Domain $o): bool
{
return $this->addresses
->filter(fn($item)=>$item->zone->domain_id === $o->id)
->count() > 0;
}
/**
* Return the system's address in the same zone
* This function can filter based on the address type needed.