<?php

namespace App\Mail;

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

class EnquiryReceived extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(public Enquiry $enquiry) {}

    public function envelope(): Envelope
    {
        $ref = strtoupper($this->enquiry->type) . '-' . str_pad((string) $this->enquiry->id, 5, '0', STR_PAD_LEFT);

        return new Envelope(
            subject: "[{$ref}] New {$this->enquiry->type} enquiry — {$this->enquiry->name}",
            replyTo: [$this->enquiry->email],
        );
    }

    public function content(): Content
    {
        return new Content(view: 'emails.enquiry-received');
    }
}
