<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $pharmacist_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 $is_online 是否在线（0:不在线 1:在线）
 * @property string $avatar 头像
 * @property int $pharmacist_title 职称
 * @property int $department_custom_id 科室id-自定义
 * @property string $department_custom_name 科室名称（如未自己输入，填入标准科室名称）
 * @property string $department_custom_mobile 科室电话
 * @property string $medical_institution 医疗机构名称
 * @property string $worker_date 医龄
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class UserPharmacist extends Model
{
    use Snowflake;

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

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['pharmacist_id', 'user_id', 'user_name', 'open_id', 'union_id', 'wx_session_key', 'status', 'is_online', 'avatar', 'pharmacist_title', 'department_custom_id', 'department_custom_name', 'department_custom_mobile', 'medical_institution', 'worker_date', 'created_at', 'updated_at'];

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