<?php

namespace App\Mail;

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

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

    public $email;

    public $nom;

    public $prenom;

    public $societe;

    public $subject;

    public $numero_suivi;

    public $lien_suivi;

    public $numero_commande;

    public $adresse;

    public $cp;

    public $ville;

    public $date_expedition;

    public $facture;

    public $mode_livraison;

    protected static $templateModelClass = MailTemplate::class;

    public function __construct($order)
    {
        $this->prenom = $order->customer->first_name;
        $this->nom = $order->customer->last_name;
        $this->adresse = $order->delivery_address->address;
        $this->cp = $order->delivery_address->zipcode;
        $this->ville = $order->delivery_address->city;
        $this->societe = $order->customer->company;
        $this->email = $order->customer->email;
        $this->numero_suivi = $order->delivery_ref;
        $this->lien_suivi = $order->delivery_link;
        $this->numero_commande = $order->ref;
        $this->date_expedition = $order->updated_at;
        $this->facture = Invoices::getInvoiceHtml($order->invoice->id);
    }
}
