106 lines
2.7 KiB
PHP
106 lines
2.7 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $record_id 主键id
|
||
* @property int $doctor_id 医生id
|
||
* @property string $avatar 头像
|
||
* @property string $be_good_at 擅长
|
||
* @property string $brief_introduction 医生简介
|
||
* @property string $expertise_ids 专长id,逗号分隔
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class DoctorIntroductionRecord extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'doctor_introduction_record';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['record_id', 'doctor_id', 'avatar', 'be_good_at', 'brief_introduction', 'expertise_ids', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "record_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 getList(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
* @param array $data
|
||
* @return DoctorIntroductionRecord|\Hyperf\Database\Model\Model
|
||
*/
|
||
public static function addDoctorIntroductionRecord(array $data): \Hyperf\Database\Model\Model|DoctorIntroductionRecord
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
/**
|
||
* 获取信息-单条
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getLastOne(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->latest()->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 获取某种状态的最后一条数据
|
||
* @param array $params
|
||
* @param array $introduction_status
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getStatusLastOne(array $params, array $introduction_status,array $fields = ["*"]): object|null
|
||
{
|
||
return self::where($params)
|
||
->whereIn("introduction_status", $introduction_status)
|
||
->latest()
|
||
->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 删除
|
||
* @param array $params
|
||
* @return int|mixed
|
||
*/
|
||
public static function del(array $params): mixed
|
||
{
|
||
return self::where($params)->delete();
|
||
}
|
||
|
||
}
|