<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TimeseriesKeyMaster extends Model
{
    use HasFactory;

    protected $table = 'timeseries_key_master';

    protected $fillable = [
        'device_profile_xid',
        'key_name',
        'display_name',
        'display_on_dashboard',
        'display_on_popup'
    ];

    public function deviceProfile()
    {
        return $this->belongsTo(DeviceProfileMaster::class, 'device_profile_xid', 'id');
    }

    public function device()
    {
        return $this->belongsTo(Device::class, 'device_profile_xid', 'device_profile_id');
    }

    public function timeseriesAlert()
    {
        return $this->hasMany(TimeseriesAlertMessage::class, 'timeseries_key_master_xid', 'id');
    }
}
