<?php

declare(strict_types=1);

namespace Kylin\Medical\Models;

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

/**
 * 科室模型
 *
 * 管理医院科室信息，包括科室名称、简介、上级科室等。
 *
 * @property string $name         科室名称
 * @property string $description  科室描述
 * @property int    $parent_id    上级科室ID
 */
class Department extends Model
{
    protected $table = 'departments';

    protected $fillable = [
        'name',
        'type',
        'description',
        'status',
        'sort_order',
    ];

    protected $casts = [
        'status' => 'boolean',
        'sort_order' => 'integer',
    ];

    /**
     * 科室下的医生
     */
    public function doctors(): HasMany
    {
        return $this->hasMany(Doctor::class);
    }

    /**
     * 科室排班
     */
    public function schedules(): HasMany
    {
        return $this->hasMany(Schedule::class);
    }
}
