<?php

namespace App\Modules\HR\Attendance\Notifications;

use App\Modules\HR\Attendance\Models\AttendanceRecord;
use App\Support\NotificationCategory;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class MissingCheckoutReminderNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public readonly AttendanceRecord $record,
    ) {}

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

    /**
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        $date = $this->record->attendance_date?->format('Y-m-d') ?? '';

        return [
            'category' => NotificationCategory::ATTENDANCE,
            'type' => 'attendance_missing_checkout',
            'attendance_record_id' => (int) $this->record->id,
            'title' => __('attendance.self.reminder_title'),
            'body' => __('attendance.self.reminder_body', ['date' => $date]),
        ];
    }
}
