<?php

namespace App\Jobs;

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 SendShortCodeListToFinance implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $short_code_list;
    protected $message_body;
    protected $finance_arr;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($short_code_list, $message_body, $finance_arr)
    {
        $this->short_code_list = $short_code_list;
        $this->message_body = $message_body;
        $this->finance_arr = $finance_arr;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle(Mailer $mailer)
    {
        $short_code_list = $this->short_code_list;
        $message_body = $this->message_body;
        $finance_arr = $this->finance_arr;
        
        $emails = [
            'samuel@click-mobile.com', 
            'kwesi@click-mobile.com', 
            'daniel@click-mobile.com', 
            'jim@click-mobile.com', 
            'priscilla@click-mobile.com',
            'mansa@click-mobile.com'
        ];
        $data = [
            'short_code_list' => $short_code_list,
            'message_body' => $message_body,
            'finance_arr' => $finance_arr
        ];
        $mailer->send('emails.short_code_payment_alert', $data, function ($message) use ($data, $emails) {
            $message->from('alerts@click-mobile.com', 'Click Mobile ERP');
            $message->to($emails)->subject('Short Code Invoices');
        });
    }
}
