HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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');

    }
}