hospital-applets-api/app/Model/DoctorWord.php

81 lines
2.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace App\Model;
use Carbon\Carbon;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $doctor_words_id 主键id
* @property int $doctor_id 医生id
* @property int $words_type 类型1:图文问诊 2:开具处方)
* @property int $words_status 状态0:禁用 1:启用)
* @property int $sort 排序值(越大排序越靠前)
* @property string $words 常用语
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
*/
class DoctorWord extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'doctor_words';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['doctor_words_id', 'doctor_id', 'words_type', 'words_status', 'sort', 'words', 'created_at', 'updated_at'];
protected string $primaryKey = "doctor_words_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 Collection|array
*/
public static function getList(array $params, array $fields = ['*']): Collection|array
{
return self::where($params)->orderBy('sort','desc')->get($fields);
}
/**
* 新增
* @param array $data
* @return \Hyperf\Database\Model\Model|DoctorWord
*/
public static function addDoctorWord(array $data): \Hyperf\Database\Model\Model|DoctorWord
{
return self::create($data);
}
/**
* 删除
* @param array $params
* @return int|mixed
*/
public static function deleteDoctorWord(array $params): mixed
{
return self::where($params)->delete();
}
}