<?php

declare(strict_types=1);

namespace Kylin\Hr\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * 绩效计划模型
 *
 * 管理公司绩效考核计划，包括考核周期、指标等。
 *
 * @property string $name      计划名称
 * @property string $start_date 开始日期
 * @property string $end_date   结束日期
 * @property string $cycle     考核周期
 */
class PerformancePlan extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'name',
        'cycle',
        'start_date',
        'end_date',
        'scoring_method',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'start_date' => 'date',
            'end_date' => 'date',
            'status' => 'integer',
        ];
    }

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

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