<?php

namespace App\Models;

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

class Kompetensi extends Model
{
    use HasFactory;

    protected $table = 'kompetensi';

    protected $fillable = [
        'nama_kompetensi',
        'jenis_kompetensi',
        'deskripsi',
    ];

    public function indikator(): HasMany
    {
        return $this->hasMany(IndikatorKompetensi::class);
    }

    public function deskripsiJenjang(): HasMany
    {
        return $this->hasMany(DeskripsiKompetensiJenjang::class);
    }

    public function standarJabatan(): HasMany
    {
        return $this->hasMany(StandarKompetensiJabatan::class);
    }

    public function rekomendasiPelatihan(): HasMany
    {
        return $this->hasMany(RekomendasiPelatihan::class);
    }

    public function getJenisLabelAttribute(): string
    {
        return match ($this->jenis_kompetensi) {
            'manajerial' => 'Kompetensi Manajerial',
            'sosial_kultural' => 'Kompetensi Sosial Kultural',
            default => 'Kompetensi',
        };
    }
}
