Command to list number of mail waiting for a system

This commit is contained in:
Deon George 2022-12-04 13:32:46 +11:00
parent 05528f1c33
commit 21236b6871

View File

@ -0,0 +1,46 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\System;
class PacketSystem extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'packet:system'
.' {sid : System ID}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Show mail waiting for a system';
/**
* Execute the console command.
*
* @return mixed
* @throws \App\Classes\FTN\InvalidPacketException
*/
public function handle()
{
$so = System::findOrFail($this->argument('sid'));
foreach ($so->addresses as $ao) {
$pkt = $ao->getEchomail(FALSE);
$this->info(sprintf('System address [%s] has [%d] messages.',$ao->ftn,$pkt?->count()));
if ($pkt) {
foreach ($pkt as $msg)
$this->warn(sprintf('- %s',$msg->msgid));
}
}
}
}