<?php

namespace App\Models;

use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Agenda extends Model
{
    use Uuid;

    public $incrementing = false;
    
    protected $table = 'ms_agenda';

    protected $keyType = 'string';

    protected $fillable = [
        'id',
        'nama',
        'tanggal',
        'waktu',
        'lokasi',
        'statusacara',
        'idunit',
        'idkategori',
        'linkzoom',
        'created_at',
        'updated_at',
        'deleted_at',
        'userid_created',
        'userid_updated',
        'idzoom',
        'passcode'
    ];

    // public function rUserAgenda()
    // {
    //     return $this->hasMany(UserAgenda::class, 'id', 'idagenda');
    // }

    public function rUnit()
    {
        return $this->belongsTo(Unit::class, 'idunit', 'id');
    }

    public function rKategori()
    {
        return $this->hasOne(Kategori::class, 'idkategori', 'id');
    }

    public function rAttachment()
    {
        return $this->hasMany(Attachment::class, 'idattachment', 'id');
    }

    public function rPegawai()
    {
        return $this->belongsToMany(Pegawai::class, 'tr_agenda_pegawai', 'idagenda', 'idpegawai');
    }
}
