<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TerminalSyncLog extends Model
{
    /**
     * 可批量赋值的属性
     *
     * @var array<string>
     */
    protected $fillable = [
        'terminal_id',
        'status',
        'config_snapshot',
        'synced_at',
        'error_message',
    ];

    /**
     * 属性类型转换
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'config_snapshot' => 'array',
            'synced_at' => 'datetime',
        ];
    }

    /**
     * 获取同步日志所属的终端
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function terminal()
    {
        return $this->belongsTo(Terminal::class);
    }
}
