<?php

declare(strict_types=1);

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage;
use Illuminate\Notifications\Notification;

class HorizonStuck extends Notification
{
    use Queueable;

    public function __construct(private string $reason)
    {
    }

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

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->error()
            ->subject('[W·Dot] Horizon stuck / not running')
            ->line($this->reason);
    }

    public function toSlack(object $notifiable): SlackMessage
    {
        return (new SlackMessage)->error()->content("*Horizon stuck*: {$this->reason}");
    }
}
