allocatr/application/admin/model/OrderDispatch.php
2025-03-03 15:36:51 +08:00

85 lines
1.7 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class OrderDispatch extends Model
{
// 表名
protected $name = 'order_dispatch';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $deleteTime = false;
// 追加属性
protected $append = [
'type_text',
'status_text',
'is_notice_text'
];
public function getTypeList()
{
return ['1' => __('Type 1')];
}
public function getStatusList()
{
//return ['0' => __('Status 0'), '1' => __('Status 1'), '10' => __('Status 10')];
return [ '1' => __('Status 1'), '10' => __('Status 10')];
}
public function getIsNoticeList()
{
return ['0' => __('Is_notice 0'), '1' => __('Is_notice 1')];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ?: ($data['type'] ?? '');
$list = $this->getTypeList();
return $list[$value] ?? '';
}
public function getStatusTextAttr($value, $data)
{
$value = $value ?: ($data['status'] ?? '');
$list = $this->getStatusList();
return $list[$value] ?? '';
}
public function getIsNoticeTextAttr($value, $data)
{
$value = $value ?: ($data['is_notice'] ?? '');
$list = $this->getIsNoticeList();
return $list[$value] ?? '';
}
public function order()
{
return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}