Command to list number of mail waiting for a system
This commit is contained in:
parent
05528f1c33
commit
21236b6871
46
app/Console/Commands/PacketSystem.php
Normal file
46
app/Console/Commands/PacketSystem.php
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user