<?php

namespace App\Jobs;
use App\Models;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Mail\Mailer;

class SendClientContractRenewalAlert implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $renewalSet;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($renewalSet)
    {
        $this->renewalSet = $renewalSet;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
     public function handle(Mailer $mailer){
          $renewalSet = $this->renewalSet;
          $emails = ['samuel@click-mobile.com'];
          $emails = ['kwesi@click-mobile.com'];
          $emails = ['effie@click-mobile.com'];
          $emails[] = $renewalSet['account_manager_email'];
          $data = [
             'client_name' => $renewalSet['client_name'],
             'alert_body' => 'Contract for ' . $renewalSet['client_name'] . ' will expire in ' . $renewalSet['days_to_expire'] . ' days. Take note'
           ];

          $mailer->send('emails.client_renewal-alert', $data, function ($message) use ($data, $emails) {
             $message->from('alerts@click-mobile.com', 'Click Mobile ERP');
             $message->to($emails)->subject('Client Contract Renewal Alert');
         });
     }
}
