Transfering netmail via EMSI
This commit is contained in:
@@ -53,7 +53,8 @@ class Address extends Model
|
||||
return $this->hasMany(self::class,'hub_id','id');
|
||||
|
||||
case 'node':
|
||||
return NULL;
|
||||
// Nodes dont have children, but must return a relationship instance
|
||||
return $this->hasOne(self::class,NULL,'void');
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown role: '.$this->role);
|
||||
@@ -151,18 +152,24 @@ class Address extends Model
|
||||
|
||||
/**
|
||||
* Get netmail for this node (including it's children)
|
||||
*
|
||||
* @return Packet|null
|
||||
*/
|
||||
public function getNetmail(): Packet
|
||||
public function getNetmail(): ?Packet
|
||||
{
|
||||
$o = new Packet($this);
|
||||
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id)))->count()) {
|
||||
$o = new Packet($this);
|
||||
|
||||
foreach (Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id))->get() as $oo) {
|
||||
$o->addNetmail($oo->packet());
|
||||
foreach ($x->get() as $oo) {
|
||||
$o->addNetmail($oo->packet());
|
||||
|
||||
// @todo We need to mark the netmail as sent
|
||||
// @todo We need to mark the netmail as sent
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
return $o;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user