<?php

namespace App\Mail;

use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class CustomerOrderStatusUpdatedMail extends Mailable
{
    use Queueable;
    use SerializesModels;

    public function __construct(public Order $order)
    {
        $this->order->loadMissing(['customer', 'items']);
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: "Order update: {$this->order->statusLabel()} - {$this->order->order_number}"
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.customer-order-status-updated',
            with: ['order' => $this->order]
        );
    }
}
