<?php

namespace App\Models;

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

class AppraisalCompetency extends Model
{
    use HasFactory;

    protected $fillable = [
        'appraisal_id',
        'category',
        'name',
        'expectations',
        'max_score',
        'q1_rating',
        'q2_rating',
        'q3_rating',
        'q4_rating',
        'employee_rating',
        'supervisor_rating',
        'score',
        'sort_order',
    ];

    protected function casts(): array
    {
        return [
            'max_score' => 'decimal:2',
            'employee_rating' => 'decimal:2',
            'supervisor_rating' => 'decimal:2',
            'score' => 'decimal:2',
            'sort_order' => 'integer',
        ];
    }

    public const CATEGORY_LABELS = [
        'generic' => 'Generic Competencies',
        'functional' => 'Functional Competencies',
        'ethics_and_values' => 'Ethics and Values',
    ];

    public function appraisal(): BelongsTo
    {
        return $this->belongsTo(Appraisal::class);
    }
}
