<?php

namespace App\Models;

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

class Pegawai extends Model
{
    public $incrementing = false;
    protected $table = 'pegawai';

    protected $fillable = [
        'id',
        'nama',
        'nip',
        'idunit',
        'statusaktif',
        'created_at',
        'updated_at',
        'deleted_at',
    ];

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

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

    public function rUsers()
    {
        return $this->hasOne(Users::class, 'idpegawai', 'id');
    }

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