<?php

declare(strict_types=1);

namespace App\Model;



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

/**
 * @property int $family_health_id 主键id
 * @property int $family_id 家庭成员id
 * @property int $patient_id 患者id
 * @property int $disease_class_id 疾病分类id-系统
 * @property string $disease_class_name 疾病名称-系统
 * @property string $diagnosis_date 确诊日期
 * @property string $diagnosis_hospital 确诊医院
 * @property string $drugs_name 正在服药名称
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class PatientFamilyHealth extends Model
{
    use Snowflake;

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

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['family_health_id', 'family_id', 'patient_id', 'disease_class_id', 'disease_class_name', 'diagnosis_date', 'diagnosis_hospital', 'drugs_name', 'created_at', 'updated_at'];

    protected string $primaryKey = "family_health_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 array $data
     * @return int
     */
    public static function edit(array $params = [], array $data = []): int
    {
        return self::where($params)->update($data);
    }


    /**
     * 新增
     * @param array $data
     * @return \Hyperf\Database\Model\Model|PatientFamilyHealth
     */
    public static function addPatientFamilyHealth(array $data = []): \Hyperf\Database\Model\Model|PatientFamilyHealth
    {
        return self::create($data);
    }
}
