<?php

namespace App\Models;

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

class DomainSyncLog extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    protected $fillable = [
        'client_domain_id',
        'old_status',
        'new_status',
        'old_expire_date',
        'new_expire_date',
        'sync_source',
        'status_changed',
        'expiry_changed',
        'client_notified',
        'admin_notified',
        'registrar_response',
        'error',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'old_expire_date' => 'date',
        'new_expire_date' => 'date',
        'status_changed' => 'boolean',
        'expiry_changed' => 'boolean',
        'client_notified' => 'boolean',
        'admin_notified' => 'boolean',
    ];

    /**
     * Get the client domain that this sync log belongs to.
     */
    public function clientDomain(): BelongsTo
    {
        return $this->belongsTo(ClientDomain::class);
    }
}
