<?php

namespace Daylight\Core\Modules\FormBuilder\Notifications;

use Daylight\Core\Modules\FormBuilder\Models\Form;
use Daylight\Core\Modules\FormBuilder\Models\FormSubmission;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class FormAutoReplyNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public Form $form,
        public FormSubmission $submission,
    ) {}

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $subject = $this->form->auto_reply_subject ?: __('daylight::forms.auto_reply_default_subject');
        $body = $this->form->auto_reply_message ?: __('daylight::forms.auto_reply_default_message');

        return (new MailMessage)
            ->subject($subject)
            ->greeting(__('daylight::forms.auto_reply_greeting'))
            ->line($body);
    }
}
