File: D:/HostingSpaces/SBogers10/vebon.komma.pro/app/Console/Commands/RemindOpenAudits.php
<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
class RemindOpenAudits extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'reminder:open-audits {type}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This command will send an reminder email to the members with an open audit';
/**
* Create a new command instance.
*
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$type = $this->argument('type');
$this->comment($this->description);
\Log::info($this->description);
//Load the auditService
$auditService = \App::make('KommaApp\Audit\AuditService');
$year = Carbon::now()->yearIso;
//Get all the unclosed audits
$audits = $auditService->getOpenAudits($year);
if ($audits->count() == 0) {
$this->comment('No open audits found');
\Log::info('No open audits found');
return;
}
$this->comment($audits->count() . ' member will receive a reminder email');
\Log::info($audits->count() . ' member will receive a reminder email');
$auditService->sendReminderEmails($audits, $type);
$this->comment('All emails queued and ready to send');
\Log::info('All emails queued and ready to send');
}
}