clrghouz/app/Console/Commands/PacketSystem.php

46 lines
891 B
PHP
Raw Normal View History

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