<?php

namespace App\Models;

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


class MessageModel extends Model
{
    use HasFactory;
    use SoftDeletes;

    protected $table = 'messages';
    protected $primaryKey = 'uuid';
    
    protected $fillable = [
        'uuid_device_results',
        'title',
        'message',
        'date_time',
        'send_by',
        'uuid_user',
        'siaga',
        'uuid_device',
        'uuid_group',
    ];
    protected $dates = ['deleted_at'];

    public $timestamps = false;

    public function setting_siaga()
    {
        return $this->belongsTo(SettingSiagaModel::class,'uuid_setting_siaga');
    }

    public function device_result()
    {
        return $this->belongsTo(DeviceResultModel::class,'uuid_device_results');
    }

    public function device()
    {
        return $this->belongsTo(DeviceModel::class,'uuid_device');
    }

    public function kelompok()
    {
        return $this->belongsTo(GroupModel::class,'uuid_group');
    }
}
