Optimise Zone::class to identify region/hosts/hubs
This commit is contained in:
@@ -36,6 +36,44 @@ class Zone extends Model
|
||||
return $this->belongsTo(Domain::class);
|
||||
}
|
||||
|
||||
public function hosts()
|
||||
{
|
||||
return $this->hasMany(Address::class)
|
||||
->where(function($query) {
|
||||
return $query
|
||||
->where(fn($q)=>$q->where('node_id',0)->where('point_id',0))
|
||||
->orWhere('role',Address::NODE_HC);
|
||||
})
|
||||
->FTNorder()
|
||||
->with(['system','zone.domain']);
|
||||
}
|
||||
|
||||
public function hubs()
|
||||
{
|
||||
// @todo we should be able to add to this query, to count children of an address by using a group by?
|
||||
return $this->hasMany(Address::class)
|
||||
->where(function($query) {
|
||||
return $query
|
||||
->where(fn($q)=>$q->where('point_id',0))
|
||||
->orWhere('role',Address::NODE_HC);
|
||||
})
|
||||
->FTNorder()
|
||||
->with(['system','zone.domain']);
|
||||
}
|
||||
|
||||
public function regions()
|
||||
{
|
||||
return $this->hasMany(Address::class)
|
||||
->where(function($query) {
|
||||
return $query
|
||||
->where(fn($q)=>$q->where('node_id',0)->where('point_id',0))
|
||||
->orWhere('role',Address::NODE_RC);
|
||||
})
|
||||
->orderBy('region_id')
|
||||
->active()
|
||||
->with(['system','zone.domain']);
|
||||
}
|
||||
|
||||
public function system()
|
||||
{
|
||||
return $this->belongsTo(System::class);
|
||||
|
Reference in New Issue
Block a user