<?php
/**
 * Created by PhpStorm.
 * User: sunil
 * Date: 9/29/18
 * Time: 4:30 PM
 */

namespace App\Console\Commands;


use App\CampaignsJobProvider;
use App\Services;
use Illuminate\Console\Command;

class CampaignReminders extends Command
{

    protected $signature = 'campaign:Reminder {--from=} {--id=}';
    private $from;
    public $job_id;

    public function __construct(){

        parent::__construct();
    }

    public function handle(){
        $start_time = time();
        if (\app()->runningInConsole()) {
            $this->from = $this->option('from');
            $this->job_id = $this->option('id');
        }
        $job = (new CampaignsJobProvider())->start($this);
        if(!$job){
            $this->comment('No Pending Jobs');
        }else{
            $this->comment('Jobs successfully executed');
        }
        (new Services())->log($this->signature, ['status' => true, 'service_count' => 1, 'start_time' => $start_time]);
    }
}