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.
88 lines
2.2 KiB
88 lines
2.2 KiB
<?php
|
|
namespace app\index\model\wanlshop;
|
|
|
|
use think\Model;
|
|
use traits\model\SoftDelete;
|
|
|
|
class GoodsComment extends Model
|
|
{
|
|
|
|
use SoftDelete;
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'wanlshop_goods_comment';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
protected $deleteTime = 'deletetime';
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'state_text',
|
|
'status_text'
|
|
];
|
|
|
|
// 将图片数组转字符串输入
|
|
public function getImagesAttr($value)
|
|
{
|
|
return $value ? explode(',', $value):[];
|
|
}
|
|
|
|
public function getStateList()
|
|
{
|
|
return ['0' => __('State 0'), '1' => __('State 1'), '2' => __('State 2')];
|
|
}
|
|
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
|
|
}
|
|
|
|
|
|
public function getStateTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
|
|
$list = $this->getStateList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
|
$list = $this->getStatusList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function goods()
|
|
{
|
|
return $this->belongsTo('app\index\model\wanlshop\Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function groups()
|
|
{
|
|
return $this->belongsTo('app\index\model\wanlshop\groups\Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function ordergoods()
|
|
{
|
|
return $this->belongsTo('app\index\model\wanlshop\OrderGoods', 'order_goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
public function ordergroups()
|
|
{
|
|
return $this->belongsTo('app\index\model\wanlshop\groups\OrderGoods', 'order_goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
}
|
|
|