Files
hospital-applets-api/app/Model/UserPatient.php
T
2023-02-17 17:10:16 +08:00

80 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $patient_id 主键id
* @property int $user_id 用户id
* @property string $user_name 用户名称
* @property string $open_id 微信open_id
* @property string $union_id 微信开放平台唯一标识
* @property string $wx_session_key 微信会话密钥
* @property int $status 状态(0:禁用 1:正常 2:删除)
* @property int $idcard_status 实名认证状态(0:未认证 1:认证通过 2:认证失败)
* @property string $mobile 手机号
* @property int $sex 性别(0:未知 1:男 2:女)
* @property int $age 年龄
* @property string $avatar 头像
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class UserPatient extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'user_patient';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['patient_id', 'user_id', 'user_name', 'open_id', 'union_id', 'wx_session_key', 'status', 'idcard_status', 'mobile', 'sex', 'age', 'avatar', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['patient_id' => 'integer', 'user_id' => 'integer', 'status' => 'integer', 'idcard_status' => 'integer', 'sex' => 'integer', 'age' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "patient_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 $data 新增数据
* @return UserPatient|\Hyperf\Database\Model\Model
*/
public static function addUserPatient(array $data): UserPatient|\Hyperf\Database\Model\Model
{
return self::create($data);
}
/**
* 修改患者-批量
* @param array $params
* @param array $data
* @return int
*/
public static function editUserPatient(array $params = [], array $data = []) : int
{
return self::where($params)->update($data);
}
}