<?php

namespace App\Services;

use App\Models\ReminderLog;

/**
 * Persists reminder / notification delivery attempts (email channel today; extensible).
 */
class NotificationLogService
{
    public function createPending(array $attributes): ReminderLog
    {
        return ReminderLog::create(array_merge([
            'status' => 'pending',
            'channel' => 'email',
        ], $attributes));
    }

    public function markSent(ReminderLog $log): void
    {
        $log->update([
            'status' => 'sent',
            'sent_at' => now(),
            'error_message' => null,
        ]);
    }

    public function markFailed(ReminderLog $log, string $message): void
    {
        $log->update([
            'status' => 'failed',
            'error_message' => $message,
        ]);
    }
}
