<?php

declare(strict_types=1);

namespace App\Model;



use Hyperf\Snowflake\Concern\Snowflake;

/**
 * @property int $record_id 主键id
 * @property int $doctor_id 医生id
 * @property int $inquiry_config_id 接诊配置id
 * @property string $old_price 原价格
 * @property string $new_price 新价格
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 */
class DoctorInquiryPriceRecord extends Model
{
    use Snowflake;

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

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['record_id', 'doctor_id', 'inquiry_config_id', 'old_price', 'new_price', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['record_id' => 'integer', 'doctor_id' => 'integer', 'inquiry_config_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    protected string $primaryKey = "record_id";

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

    /**
     * 获取数量
     * @param array $params
     * @return int
     */
    public static function getCount(array $params): int
    {
        return self::where($params)->count();
    }

    /**
     * 新增
     * @param array $data
     * @return DoctorInquiryPriceRecord|\Hyperf\Database\Model\Model
     */
    public static function addRecord(array $data): \Hyperf\Database\Model\Model|DoctorInquiryPriceRecord
    {
        return self::create($data);
    }
}
