<?php

namespace App\Notifications;

use App\Models\DisciplinaryCase;
use Illuminate\Notifications\Messages\MailMessage;

class DisciplinaryCaseUpdatedNotification extends BaseSchoolNotification
{
    public function __construct(
        private readonly DisciplinaryCase $case,
        private readonly string $event = 'updated'
    ) {}

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $title = $this->event === 'submitted'
            ? 'New disciplinary case reported'
            : 'Disciplinary case updated';

        return $this->databasePayload(
            $title,
            "{$this->case->case_number}: {$this->case->title} — {$this->case->stage}",
            'disciplinary_case',
            url('/dashboard')
        );
    }

    public function toMail(object $notifiable): MailMessage
    {
        $subject = $this->event === 'submitted'
            ? "New case {$this->case->case_number} reported"
            : "Case {$this->case->case_number} updated";

        return $this->mailMessage(
            $subject,
            'Hello '.$notifiable->name.',',
            "Case {$this->case->case_number} ({$this->case->title}) is now at stage: ".str_replace('_', ' ', $this->case->stage).'.',
        );
    }
}
