2021-04-01 10:59:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
2021-06-24 10:16:37 +00:00
|
|
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
2021-04-01 10:59:15 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2023-07-07 13:59:04 +00:00
|
|
|
use App\Models\{Address,Mailer};
|
2021-09-20 10:39:03 +00:00
|
|
|
use App\Jobs\AddressPoll as Job;
|
2021-04-01 10:59:15 +00:00
|
|
|
|
2022-06-26 14:14:36 +00:00
|
|
|
class CommEMSISend extends Command
|
2021-04-01 10:59:15 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2024-10-19 02:38:55 +00:00
|
|
|
protected $signature = 'comm:emsi:send'
|
|
|
|
.'{--N|now : Dont queue}'
|
|
|
|
.'{ftn : FTN to Send to}';
|
2021-04-01 10:59:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'EMSI send';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
2021-09-20 10:39:03 +00:00
|
|
|
* @throws \Exception
|
2021-04-01 10:59:15 +00:00
|
|
|
*/
|
2024-10-19 02:38:55 +00:00
|
|
|
public function handle()
|
2021-04-01 10:59:15 +00:00
|
|
|
{
|
2021-09-20 10:39:03 +00:00
|
|
|
$ao = Address::findFTN($this->argument('ftn'));
|
|
|
|
if (! $ao)
|
2021-06-24 10:16:37 +00:00
|
|
|
throw new ModelNotFoundException('Unknown node: '.$this->argument('ftn'));
|
|
|
|
|
2023-07-26 09:44:07 +00:00
|
|
|
Log::info(sprintf('CES:- Call EMSI send for %s',$ao->ftn));
|
|
|
|
|
2024-11-08 12:31:21 +00:00
|
|
|
$mo = Mailer::where('name','EMSI')->sole();
|
2023-07-26 09:44:07 +00:00
|
|
|
|
2024-10-20 21:47:54 +00:00
|
|
|
if ($this->option('now'))
|
|
|
|
Job::dispatchSync($ao,$mo);
|
|
|
|
else
|
|
|
|
Job::dispatch($ao,$mo);
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
2021-04-01 10:59:15 +00:00
|
|
|
}
|
|
|
|
}
|