hospital-applets-api/app/Model/OrderEvaluation.php
2023-02-17 17:10:16 +08:00

67 lines
2.3 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 Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $evaluation_id 主键id
* @property int $doctor_id 医生id
* @property int $patient_id 患者id
* @property int $order_inquiry_id 订单-问诊id
* @property string $reply_quality 回复质量(百分制)
* @property string $service_attitude 服务态度(百分制)
* @property string $reply_progress 回复速度(百分制)
* @property string $avg_score 平均得分(百分制)
* @property int $type 类型1:默认评价 2:主动评价)
* @property string $content 评价内容
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class OrderEvaluation extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'order_evaluation';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['evaluation_id', 'doctor_id', 'patient_id', 'order_inquiry_id', 'reply_quality', 'service_attitude', 'reply_progress', 'avg_score', 'type', 'content', 'created_at', 'updated_at'];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['evaluation_id' => 'integer', 'doctor_id' => 'integer', 'patient_id' => 'integer', 'order_inquiry_id' => 'integer', 'type' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
protected string $primaryKey = "evaluation_id";
/**
* 获取评价列表-分页
* @param array $params 条件
* @param array $fields 字段
* @param int|null $page 页码
* @param int|null $per_page 每页个数
* @return array
*/
public static function getPage(array $params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array
{
$raw = self::where($params)->paginate($per_page, $fields, "page", $page);
$data = array();
$data['current_page'] = $raw->currentPage();// 当前页码
$data['total'] = $raw->total();//数据总数
$data['data'] = $raw->items();//数据
$data['per_page'] = $raw->perPage();//每页个数
$data['last_page'] = $raw->lastPage();//最后一页
return $data;
}
}