<?php

namespace App\Models;

use App\Enums\SmsSendStatus;
use Database\Factories\SmsSendLogFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SmsSendLog extends Model
{
    /** @use HasFactory<SmsSendLogFactory> */
    use HasFactory;

    protected $fillable = [
        'sms_campaign_id',
        'coupon_id',
        'phone',
        'message',
        'status',
        'error_message',
        'attempted_at',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'status' => SmsSendStatus::class,
            'attempted_at' => 'datetime',
        ];
    }

    public function campaign(): BelongsTo
    {
        return $this->belongsTo(SmsCampaign::class, 'sms_campaign_id');
    }

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