Transfering netmail via EMSI

This commit is contained in:
Deon George
2021-07-17 15:48:07 +10:00
parent 6ce4e64cb6
commit 1fa566b26c
15 changed files with 226 additions and 83 deletions

View File

@@ -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;
}
/**