<?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 $level       职级
 * @property int    $department_id 所属部门
 */
class Position extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'department_id',
        'name',
        'code',
        'level',
        'category',
        'status',
    ];

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

    /**
     * 所属部门
     */
    public function department(): BelongsTo
    {
        return $this->belongsTo(Department::class);
    }

    /**
     * 岗位员工
     */
    public function employees(): HasMany
    {
        return $this->hasMany(Employee::class);
    }
}
