109 lines
3.4 KiB
PHP
109 lines
3.4 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Relations\HasOne;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $inquiry_config_id 主键id
|
||
* @property int $doctor_id 医生id
|
||
* @property int $system_inquiry_config_id 系统问诊配置表id
|
||
* @property int $inquiry_type 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||
* @property int $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员)
|
||
* @property int $work_num_day 每日接诊数量
|
||
* @property string $inquiry_price 接诊价格(专家问诊-公益问诊)
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
* @property-read SystemInquiryConfig $SystemInquiryConfig
|
||
*/
|
||
class DoctorInquiryConfig extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'doctor_inquiry_config';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['inquiry_config_id', 'doctor_id', 'system_inquiry_config_id', 'inquiry_type', 'inquiry_mode', 'work_num_day', 'inquiry_price', 'created_at', 'updated_at'];
|
||
|
||
/**
|
||
* The attributes that should be cast to native types.
|
||
*/
|
||
protected array $casts = ['inquiry_config_id' => 'integer', 'doctor_id' => 'integer', 'system_inquiry_config_id' => 'integer', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'work_num_day' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||
|
||
protected string $primaryKey = "inquiry_config_id";
|
||
|
||
/**
|
||
* 关联系统问诊配置表
|
||
*/
|
||
public function SystemInquiryConfig(): HasOne
|
||
{
|
||
return $this->hasOne(SystemInquiryConfig::class, 'system_inquiry_config_id', 'system_inquiry_config_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 object|null
|
||
*/
|
||
public static function getInquiryConfigOne(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::with(['SystemInquiryConfig'])->where($params)->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 获取医生接诊配置信息-多条
|
||
* 在线问诊+专家问诊
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getInquiryConfigList(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::with(['SystemInquiryConfig'])
|
||
->where($params)->whereIn("inquiry_type",[1,3])->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 创建
|
||
* @param array $data
|
||
* @return \Hyperf\Database\Model\Model|DoctorInquiryConfig
|
||
*/
|
||
public static function addInquiryConfig(array $data): \Hyperf\Database\Model\Model|DoctorInquiryConfig
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
/**
|
||
* 修改医生接诊配置
|
||
* @param array $params
|
||
* @param array $data
|
||
* @return int
|
||
*/
|
||
public static function editInquiryConfig(array $params = [], array $data = []): int
|
||
{
|
||
return self::where($params)->update($data);
|
||
}
|
||
}
|