<?php

namespace App\Jobs;

use App\Mail\DemandeContact;
use APPLICATION;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

class EnvoyerDemandeContact implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    protected $_contact_name;
    protected $_contact_company;
    protected $_contact_email;
    protected $_contact_phone;
    protected $_contact_message;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($contact_name, $contact_company, $contact_email, $contact_phone, $contact_message)
    {
        $this->_contact_name = $contact_name;
        $this->_contact_company = $contact_company;
        $this->_contact_email = $contact_email;
        $this->_contact_phone = $contact_phone;
        $this->_contact_message = $contact_message;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Mail::to(APPLICATION::ADMIN_MAIL)->send(new DemandeContact(
            $this->_contact_name,
            $this->_contact_company,
            $this->_contact_email,
            $this->_contact_phone,
            $this->_contact_message
        ));
    }
}
