<?php

declare(strict_types=1);

namespace App\Model;



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

/**
 * @property int $cert_id 主键id
 * @property int $user_id 用户id
 * @property string $cert_base64 签名值证书
 * @property string $cert_chain_p7 证书链
 * @property string $cert_serial_number 证书序列号
 * @property string $ca_pin ca认证pin值
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class DoctorPharmacistCert extends Model
{
    use Snowflake;

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

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['cert_id', 'user_id', 'cert_base64', 'cert_chain_p7', 'cert_serial_number', 'ca_pin', 'created_at', 'updated_at'];

    protected string $primaryKey = "cert_id";

    /**
     * 获取是否存在
     * @param array $params
     * @return bool
     */
    public static function getExists(array $params): bool
    {
        return self::where($params)->exists();
    }

    /**
     * 获取信息-单条
     * @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|DoctorPharmacistCert
     */
    public static function addDoctorPharmacistCert(array $data = []): \Hyperf\Database\Model\Model|DoctorPharmacistCert
    {
        return self::create($data);
    }
}
