<?php

namespace App\Mail\Feedback;

use App\Models\Objects\NirObject;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class NotifyFeedbackFormSubmitted extends Mailable implements ShouldQueue {
    use Queueable, SerializesModels;

    public NirObject $object;

    public function __construct(NirObject $object) {
        $this->object = $object;
    }

    public function build(): NotifyFeedbackFormSubmitted {
        $this->subject('Поступило новое обращение')->view('mail.feedback.submitted');
        $this->object->attachedFiles->each(function($asset) {
            $this->attachFromStorage($asset->path);
        });
        return $this;
    }
}
