<?php

namespace App\Mail;

use App\Models\Core\Mail\MailTemplate;
use App\Repositories\Shop\Traits\MailCustomers;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Spatie\MailTemplates\TemplateMailable;

class ConfirmationCommande extends TemplateMailable
{
    use MailCustomers, Queueable, SerializesModels;

    protected static $templateModelClass = MailTemplate::class;

    public $email;

    public $nom;

    public $prenom;

    public $societe;

    public $subject;

    public $numero_commande;

    public $date_commande;

    public $facturation_adresse;

    public $facturation_cp;

    public $facturation_ville;

    public $livraison_adresse;

    public $livraison_cp;

    public $livraison_ville;

    public function __construct($order)
    {
        $this->prenom = $order->customer->first_name;
        $this->nom = $order->customer->last_name;
        $this->facturation_adresse = $order->address->address;
        $this->facturation_cp = $order->address->zipcode;
        $this->facturation_ville = $order->address->city;
        $this->livraison_adresse = $order->delivery_address->address;
        $this->livraison_cp = $order->delivery_address->zipcode;
        $this->livraison_ville = $order->delivery_address->city;
        $this->societe = $order->customer->company;
        $this->email = $order->customer->email;
        $this->numero_commande = $order->ref;
        $this->date_commande = $order->created_at;
    }
}
