<?php

declare(strict_types=1);

namespace App\Notifications;

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

class EmployeeTerminatedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly Employee $employee,
    ) {}

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

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject(__('notifications.employee_terminated.subject'))
            ->line(__('notifications.employee_terminated.line_terminated', [
                'name' => $this->employee->full_name,
                'number' => $this->employee->employee_number,
            ]))
            ->line(__('notifications.employee_terminated.termination_date') . ': ' . $this->employee->termination_date?->toDateString());
    }

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'employee_id' => $this->employee->id,
            'employee_number' => $this->employee->employee_number,
            'full_name' => $this->employee->full_name,
            'termination_date' => $this->employee->termination_date?->toDateString(),
            'department_id' => $this->employee->department_id,
        ];
    }
}
