<?php

namespace App\Jobs;

use App\Mail\DemandeDemonstration;
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 EnvoyerDemandeDemonstration implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    protected $_demo_name;
    protected $_demo_company;
    protected $_demo_email;
    protected $_demo_phone;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($demo_name, $demo_company, $demo_email, $demo_phone)
    {
        $this->_demo_name = $demo_name;
        $this->_demo_company = $demo_company;
        $this->_demo_email = $demo_email;
        $this->_demo_phone = $demo_phone;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Mail::to(APPLICATION::ADMIN_MAIL)->send(new DemandeDemonstration(
            $this->_demo_name,
            $this->_demo_company,
            $this->_demo_email,
            $this->_demo_phone
        ));
    }
}
