36 行
882 B
PHP
可执行文件
36 行
882 B
PHP
可执行文件
<?php
|
|
|
|
namespace Delivery\Model;
|
|
|
|
use think\Model;
|
|
|
|
|
|
class Post extends Model
|
|
{
|
|
|
|
// 表名
|
|
protected $name = 'paotui_post';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
protected $deleteTime = false;
|
|
|
|
|
|
public function order2()
|
|
{
|
|
return $this->belongsTo(\addons\shopro\model\Order::class, 'order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function getTotalGoodsNumAttr() {
|
|
return \addons\shopro\model\OrderItem::where('order_id', $this->order_id)->sum('goods_num');
|
|
}
|
|
|
|
public function getGoodsTitleAttr() {
|
|
return implode(',', \addons\shopro\model\OrderItem::where('order_id', $this->order_id)->column('goods_title'));
|
|
}
|
|
}
|