<?php

namespace App\Models;

use App\Enums\ReminderStatus;
use App\Models\Concerns\BelongsToBusiness;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ReminderLog extends Model
{
    use BelongsToBusiness, HasFactory;

    protected $fillable = [
        'business_id',
        'scheduled_reminder_id',
        'customer_id',
        'type',
        'channel',
        'recipient',
        'message_preview',
        'status',
        'sent_at',
        'failure_reason',
        'provider_response',
    ];

    protected function casts(): array
    {
        return [
            'sent_at' => 'datetime',
            'status' => ReminderStatus::class,
            'provider_response' => 'array',
        ];
    }

    public function scheduledReminder(): BelongsTo
    {
        return $this->belongsTo(ScheduledReminder::class);
    }

    public function customer(): BelongsTo
    {
        return $this->belongsTo(Customer::class);
    }
}
