<?php

namespace App\Notifications;

use App\Models\ReminderNotificationLog;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class LoanReminderNotification extends Notification
{
    use Queueable;

    public function __construct(public ReminderNotificationLog $log) {}

    public function via(object $notifiable): array
    {
        return ['database'];
    }

    public function toDatabase(object $notifiable): array
    {
        return [
            'event' => 'loan_payment_reminder',
            'notification_log_id' => $this->log->id,
            'loan_id' => $this->log->loan_id,
            'installment_id' => $this->log->loan_installment_id,
            'reminder_type' => $this->log->reminder_type,
            'scheduled_for' => $this->log->scheduled_for->toDateString(),
            'message' => $this->log->message,
        ];
    }

    public function toArray(object $notifiable): array
    {
        return $this->toDatabase($notifiable);
    }
}
