<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TenantNotificationLog extends Model
{
    protected $fillable = [
        'tenant_id',
        'type',
        'channel',
        'recipient',
        'status',
        'context',
        'sent_at',
        'failed_at',
        'failure_reason',
    ];

    protected $casts = [
        'context' => 'array',
        'sent_at' => 'datetime',
        'failed_at' => 'datetime',
    ];

    public function tenant()
    {
        return $this->belongsTo(Tenant::class);
    }

    public function receipts()
    {
        return $this->hasMany(TenantNotificationReceipt::class, 'notification_log_id');
    }
}
