<?php

namespace App\Modules\HR\Performance\Models;

use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use App\Modules\HR\Employees\Models\Employee;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PerformanceReview extends Model
{
    use BelongsToTenant;

    protected $table = 'hr_performance_reviews';

    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'goals' => 'array', 'kpis' => 'array', 'reviewed_at' => 'datetime',
            'promotion_recommended' => 'boolean', 'training_recommended' => 'boolean',
            'self_score' => 'decimal:2', 'manager_score' => 'decimal:2', 'final_score' => 'decimal:2',
        ];
    }

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

    public function cycle(): BelongsTo
    {
        return $this->belongsTo(PerformanceCycle::class, 'cycle_id');
    }
}
