<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class DepositEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $custom_subject;
    public $custom_message;

    public $deposit;

    /**
     * Create a new message instance.
     */
    public function __construct($custom_subject, $custom_message, $deposit)
    {
        $this->custom_subject = $custom_subject;
        $this->custom_message = $custom_message;
        $this->deposit = $deposit;
    }

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: __($this->custom_subject),
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        // Dynamically resolve view based on active template
        $template = config('site.template');
        $view = "templates.{$template}.mail.deposit-email";

        return new Content(
            markdown: $view,
            with: [
                'deposit' => $this->deposit,
                'custom_message' => $this->custom_message,
                'custom_subject' => $this->custom_subject,
            ],
        );
    }

    /**
     * Get the attachments for the message.
     *
     * @return array<int, \Illuminate\Mail\Mailables\Attachment>
     */
    public function attachments(): array
    {
        return [];
    }
}
