<?php

namespace Modules\SpecialAttendance\Listeners;

use Modules\SpecialAttendance\Entities\TardyNotification;
use Modules\SpecialAttendance\Events\TardyRecordCreated;

class NotifyLatePunchIn
{
    public function handle(TardyRecordCreated $event)
    {
        $user = $event->user;
        $tardyRecord = $event->tardyRecord;
        // if ($tardyRecord->tardy_type === 'Late Punch In') {
        // Send notification to the user regarding tardy
        TardyNotification::create([
            'user_id' => $user->id,
            'message' => 'You were late for work. Please check the details.',
            'sent_at' => now(),
            'notification_type' => 'Tardy',
            'is_read' => false,
        ]);
        // }
    }
}
