You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
10 months ago
|
<?php
|
||
|
declare (strict_types=1);
|
||
|
|
||
|
namespace app\common\model;
|
||
|
|
||
|
use app\common\enum\RecoveryStatusEnum;
|
||
|
use app\common\enum\RecoveryTypeEnum;
|
||
|
use cores\BaseModel;
|
||
|
use think\model\relation\HasMany;
|
||
|
|
||
|
class RecoveryOrder extends BaseModel
|
||
|
{
|
||
|
// 定义表名
|
||
|
protected $name = 'server_recovery';
|
||
|
|
||
|
// 定义主键
|
||
|
protected $pk = 'recovery_id';
|
||
|
/**
|
||
|
* 追加字段
|
||
|
* @var array
|
||
|
*/
|
||
|
protected $append = [
|
||
|
'order_status_text', //状态
|
||
|
'recovery_type_text', //回收方式
|
||
|
];
|
||
|
|
||
|
/**
|
||
|
* 关联图片表
|
||
|
* @return HasMany
|
||
|
*/
|
||
|
public function images(): HasMany
|
||
|
{
|
||
|
return $this->hasMany('RecoveryImage')->order(['id']);
|
||
|
}
|
||
|
|
||
|
public function getOrderStatusTextAttr($value, $data)
|
||
|
{
|
||
|
$result = RecoveryStatusEnum::data();
|
||
|
if (!empty($result[$data['order_status']]['name'])) {
|
||
|
return $result[$data['order_status']]['name'];
|
||
|
}
|
||
|
return '未知';
|
||
|
}
|
||
|
|
||
|
public function getRecoveryTypeTextAttr($value, $data)
|
||
|
{
|
||
|
$result = RecoveryTypeEnum::data();
|
||
|
if (!empty($result[$data['recovery_type']]['name'])) {
|
||
|
return $result[$data['recovery_type']]['name'];
|
||
|
}
|
||
|
return '未知';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @notes:详情
|
||
|
* @param $where
|
||
|
* @param array $with
|
||
|
* @return RecoveryOrder|array|null
|
||
|
* @author: wanghousheng
|
||
|
*/
|
||
|
public static function detail($where, array $with = [])
|
||
|
{
|
||
|
return static::get($where, $with);
|
||
|
}
|
||
|
|
||
|
}
|