<?php

namespace Kylin\Notification\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * 通知发送日志模型
 *
 * 记录每条通知在各渠道的发送状态和结果。
 */
class NotificationLog extends Model
{
    protected $table = 'kylin_notification_logs';

    protected $fillable = [
        'notification_id',
        'channel',
        'status',
        'message_id',
        'error',
        'request_params',
        'raw_response',
        'sent_at',
    ];

    protected $casts = [
        'request_params' => 'array',
        'raw_response' => 'array',
        'sent_at' => 'datetime',
    ];

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