<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SmsMessage extends Model
{
    use HasFactory;

    protected $fillable = [
        'gateway_id',
        'recipient',
        'message',
        'source',
        'status',
        'scheduled_at',
        'queued_at',
        'sent_at',
        'failed_at',
        'error_message',
        'created_by',
    ];

    protected $casts = [
        'sent_at' => 'datetime',
        'failed_at' => 'datetime',
        'scheduled_at' => 'datetime',
        'queued_at' => 'datetime',
    ];

    public function gateway()
    {
        return $this->belongsTo(SmsGateway::class, 'gateway_id');
    }

    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }
}
