allocatr/application/admin/model/OrderDispatch.php
2025-03-03 14:57:03 +08:00

68 lines
1.2 KiB
PHP

<?php
namespace app\admin\model;
use think\Model;
class OrderDispatch extends Model
{
// 表名
protected $name = 'order_dispatch';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'type_text',
'status_text'
];
public function getTypeList()
{
return ['1' => __('Type 1')];
}
public function getStatusList()
{
return ['0' => __('Status 0'), '1' => __('Status 1'), '10' => __('Status 10')];
}
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 order()
{
return $this->belongsTo('Order', 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}