<?php

namespace App\Notifications;

use App\Models\Hunts;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class HuntParticipantJoinedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public Hunts $hunt,
        public User $participant,
    ) {}

    /**
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject('Nouveau participant sur '.$this->hunt->title)
            ->view('mail.hunts.joined-hunt', [
                'notifiable' => $notifiable,
                'hunt' => $this->hunt,
                'participant' => $this->participant,
                'participantsCount' => $this->hunt->participants()->count(),
            ]);
    }
}
