初始化项目:添加后端代码、ThinkPHP框架、前端资源
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model\order;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Item extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'order_item';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'refund_time_text'
|
||||
];
|
||||
|
||||
|
||||
// 定义订单商品与订单的关联关系
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo('\app\admin\model\order\Order', 'order_no');
|
||||
}
|
||||
|
||||
|
||||
public function getGoodsTypeList()
|
||||
{
|
||||
return [
|
||||
'activity' => __('activity'),
|
||||
'composite' => __('composite'),
|
||||
'course' => __('course'),
|
||||
'exercises' => __('exercises'),
|
||||
'vipcard' => __('vipcard')
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getRefundTimeTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ? $value : (isset($data['refund_time']) ? $data['refund_time'] : '');
|
||||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||||
}
|
||||
|
||||
protected function setRefundTimeAttr($value)
|
||||
{
|
||||
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||||
}
|
||||
|
||||
|
||||
public function detail()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\Course', 'item_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user