<?php

namespace App\Models\User;

use App\Models\Biodata;
use App\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class PenelitianSumberAnggota extends Model
{
    use HasFactory;
    use UuidTrait;

    public $incrementing = false;
    protected $table = 'penelitiansumber_anggota';
    protected $keyType = 'string';

    protected $fillable = [
        'nama', 'penelitiansumber_id', 'nidn', 'peran', 'tugas', 'institusi', 'jenis', 'userid_created', 'userid_updated', 'created_at', 'updated_at',
    ];

    public const RULES = [
        'penelitiansumber_id' => 'required',
        'nidn' => 'required',
        'peran' => 'required'
    ];

    public const ERROR_MESSAGES = [
        'penelitiansumber_id.required' => 'penelitiansumber tidak boleh kosong',
        'nidn.required' => 'nidn tidak boleh kosong',
        'peran.required' => 'peran tidak boleh kosong'
    ];

    public const KEANGGOTAAN = [
        PenelitianSumberAnggota::KETUA_KEY =>'Ketua',
        PenelitianSumberAnggota::ANGGOTA_KEY =>'Anggota'
    ];

    public const KETUA_KEY = 'K';
    public const ANGGOTA_KEY = 'A';

    public function biodata()
    {
        return $this->belongsTo(Biodata::class, 'nidn', 'nidn');
    }
}
