<?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\Support\Facades\Mail;
use Exception;

use App\Mail\AssignWorkOrder;
use App\Model\WorkOrder;
use App\Model\StaffDetail;
use App\Model\Subscriber;
use App\Model\Company;

class SendWorkOrder implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    public $work_order,$staff,$recipient,$customer,$company;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(WorkOrder $work_order,StaffDetail $staff, $recipient,Subscriber $customer,Company $company)
    {
        //
        $this->work_order = $work_order;
        $this->recipient = $recipient;
        $this->staff = $staff;
        $this->customer = $customer;
        $this->company = $company;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //
        Mail::to($this->recipient)->send(new AssignWorkOrder($this->work_order,$this->staff,$this->customer,$this->company));
    }

    public function failed(Exception $exception)
    {
        //
    }
}
