<?php

namespace Modules\NX600Lab\Entities;

use Illuminate\Database\Eloquent\Model;

class NxDeviceError extends Model
{
    protected $table = 'nx_device_errors';

    protected $fillable = [
        'error_date', 'error_time', 'error_number', 'added_info',
        'device_ip', 'comm_type', 'acknowledged', 'acknowledged_at',
    ];

    protected $casts = [
        'error_date'      => 'date',
        'added_info'      => 'array',
        'acknowledged'    => 'boolean',
        'acknowledged_at' => 'datetime',
    ];

    public function acknowledge(): void
    {
        $this->update([
            'acknowledged'    => true,
            'acknowledged_at' => now(),
        ]);
    }
}
