<?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 $position_name 岗位名称
 * @property int    $headcount     招聘人数
 * @property string $status        计划状态
 */
class RecruitmentPlan extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'department_id',
        'position_id',
        'count',
        'salary_range',
        'requirements',
        'deadline',
        'status',
    ];

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

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

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

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