103 lines
3.3 KiB
PHP
103 lines
3.3 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Database\Model\Relations\HasOne;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $family_id 主键id
|
||
* @property int $patient_id 患者id
|
||
* @property int $relation 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||
* @property int $status 状态(1:正常 2:删除)
|
||
* @property int $is_default 是否默认(0:否 1:是)
|
||
* @property string $card_name 姓名
|
||
* @property string $card_name_mask 姓名(掩码)
|
||
* @property string $mobile 电话
|
||
* @property string $mobile_mask 电话(掩码)
|
||
* @property int $type 身份类型(1:身份证 2:护照 3:港澳通行证 4:台胞证)
|
||
* @property string $id_number 证件号码
|
||
* @property string $id_number_mask 证件号码(掩码)
|
||
* @property int $sex 性别(0:未知 1:男 2:女)
|
||
* @property int $age 年龄
|
||
* @property int $province_id 省份id
|
||
* @property string $province 省份
|
||
* @property int $city_id 城市id
|
||
* @property string $city 城市
|
||
* @property int $county_id 区县id
|
||
* @property string $county 区县
|
||
* @property string $height 身高(cm)
|
||
* @property string $weight 体重(kg)
|
||
* @property int $marital_status 婚姻状况(0:未婚 1:已婚 2:离异)
|
||
* @property int $nation_id 民族
|
||
* @property string $nation_name 民族名称
|
||
* @property int $job_id 职业
|
||
* @property string $job_name 职业名称
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class PatientFamily extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'patient_family';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['family_id', 'patient_id', 'relation', 'status', 'is_default', 'card_name', 'card_name_mask', 'mobile', 'mobile_mask', 'type', 'id_number', 'id_number_mask', 'sex', 'age', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'height', 'weight', 'marital_status', 'nation_id', 'nation_name', 'job_id', 'job_name', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "family_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 $data
|
||
* @return \Hyperf\Database\Model\Model|PatientFamily
|
||
*/
|
||
public static function addPatientFamily(array $data = []): \Hyperf\Database\Model\Model|PatientFamily
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
* @param array $params
|
||
* @param array $data
|
||
* @return int
|
||
*/
|
||
public static function edit(array $params = [], array $data = []): int
|
||
{
|
||
return self::where($params)->update($data);
|
||
}
|
||
}
|