clrghouz/app/Console/Commands/CommBinkpSend.php

53 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2021-04-01 10:59:15 +00:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\ModelNotFoundException;
2021-04-01 10:59:15 +00:00
use Illuminate\Support\Facades\Log;
use App\Models\{Address,Mailer};
use App\Jobs\AddressPoll as Job;
2021-04-01 10:59:15 +00:00
class CommBinkpSend extends Command
2021-04-01 10:59:15 +00:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'comm:binkp: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 = 'BINKP send';
2021-04-01 10:59:15 +00:00
/**
* Execute the console command.
*
2021-07-02 13:44:01 +00:00
* @throws \Exception
2021-04-01 10:59:15 +00:00
*/
public function handle()
2021-04-01 10:59:15 +00:00
{
$ao = Address::findFTN($this->argument('ftn'));
if (! $ao)
throw new ModelNotFoundException('Unknown node: '.$this->argument('ftn'));
2021-04-01 10:59:15 +00:00
2023-07-26 09:44:07 +00:00
Log::info(sprintf('CBS:- Call BINKP send for %s',$ao->ftn));
$mo = Mailer::where('name','BINKP')->sole();
2023-07-26 09:44:07 +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
}
}