<?php

namespace App\Mail;

use App\Settings\GeneralSettings;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class ContactReplyMail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     */
    public function __construct(
        public $contact,
        public $replyMessage,
    ) {}

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Balasan: '.($this->contact->subject ?? 'Pesan Kontak'),
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        $settings = app(GeneralSettings::class);
        $logoPath = $settings->site_logo
            ? storage_path('app/public/'.$settings->site_logo)
            : public_path('assets/img/logo/icon-with-text.png');

        return new Content(
            view: 'emails.contact-reply',
            with: [
                'name' => $this->contact->name,
                'replyMessage' => $this->replyMessage,
                'site_name' => $settings->site_name,
                'logoPath' => $logoPath,
            ],
        );
    }

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