<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Mail\Udalost;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
use Seka\Portal\Modul\Terminy\Entities\Dtos\UdalostDTO;

/**
 * Class ZrusenaUdalostMail
 *
 * @package Seka\Portal\Modul\Terminy\Mail\Udalost
 */
final class ZrusenaUdalostMail extends Mailable implements ShouldQueue
{
    use Queueable;
    use SerializesModels;

    /**
     * @var string
     */
    public $mailer = 'broadcast';

    /**
     * @var \Seka\Portal\Modul\Terminy\Entities\Dtos\UdalostDTO
     */
    public UdalostDTO $udalost;

    /**
     * ZrusenaUdalostMail constructor.
     *
     * @param \Seka\Portal\Modul\Terminy\Entities\Dtos\UdalostDTO $udalost
     */
    public function __construct(UdalostDTO $udalost)
    {
        $this->udalost = $udalost;
    }

    /**
     * @return mixed
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function build(): mixed
    {
        return $this
            ->subject(Str::ucfirst($this->udalost->druh->label()))
            ->markdown('Terminy::mail.udalost.public.zrusena')
            ->withUdalost($this->udalost)
            ->replyTo(config('terminy.podpora.email'));
    }
}
