<?php

declare(strict_types=1);

namespace Kylin\Hr\Models;

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

/**
 * 面试记录模型
 *
 * 管理面试安排和结果，包括面试官、时间、评价等。
 *
 * @property string $interviewer_name 面试官姓名
 * @property string $scheduled_at     面试时间
 * @property string $result           面试结果
 * @property string $feedback         面试评价
 */
class Interview extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'resume_id',
        'interviewer_id',
        'round',
        'type',
        'scheduled_at',
        'result',
        'score',
        'feedback',
    ];

    protected function casts(): array
    {
        return [
            'scheduled_at' => 'datetime',
            'round' => 'integer',
            'score' => 'decimal:1',
        ];
    }

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

    public function interviewer(): BelongsTo
    {
        return $this->belongsTo(Employee::class, 'interviewer_id');
    }
}
