<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $disease_class_id 主键id
 * @property string $disease_class_name 疾病分类名称
 * @property int $expertise_id 医生专长id
 * @property int $disease_class_status 状态（0:删除 1:正常）
 * @property int $disease_class_enable 是否启用（0:否 1:是）
 * @property int $icd_id 标准分类id
 * @property int $is_hot 是否热门（0:否 1:是）
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class DiseaseClass extends Model
{
    use Snowflake;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'disease_class';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['disease_class_id', 'disease_class_name', 'expertise_id', 'disease_class_status', 'disease_class_enable', 'icd_id', 'is_hot', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['disease_class_id' => 'string', 'expertise_id' => 'string', 'disease_class_status' => 'integer', 'disease_class_enable' => 'integer', 'icd_id' => 'string', 'is_hot' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected string $primaryKey = "disease_class_id";

    /**
     * 获取信息-单条
     * @param array $params
     * @param array $fields
     * @return object|null
     */
    public static function getOne(array $params, array $fields = ['*'],): object|null
    {
        return self::where($params)->first($fields);
    }

    /**
     * 获取数据-多
     * @param array $params
     * @param array $fields
     * @return Collection|array
     */
    public static function getList(array $params = [], array $fields = ['*']): Collection|array
    {
        return self::where($params)->get($fields);
    }

    /**
     * 获取数据-限制条数
     * @param array $params
     * @param int|string $limit
     * @param array $fields
     * @return Collection|array
     */
    public static function getLimit(array $params = [],int|string $limit = 5, array $fields = ['*']): Collection|array
    {
        return self::where($params)->limit($limit)->get($fields);
    }
}
