<?php

declare(strict_types=1);

namespace App\Domain\Cluster\Models;

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

class ClusterHeartbeat extends Model
{
    public $timestamps = false;

    protected $fillable = [
        'cluster_node_id',
        'load',
        'accounts_count',
        'received_at',
    ];

    protected function casts(): array
    {
        return [
            'load' => 'array',
            'accounts_count' => 'integer',
            'received_at' => 'datetime',
        ];
    }

    public function node(): BelongsTo
    {
        return $this->belongsTo(ClusterNode::class, 'cluster_node_id');
    }
}
