GoodsStyle.php 652 字节
<?php

namespace app\common\model;

use think\Model;

class GoodsStyle extends Model
{
	// 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';

    protected $append = [
        'goods_style_price'
    ];

    /**
     * 风格价格
     */
    public function getGoodsStylePriceAttr($value, $data)
    {
        $goods_style = !empty($data['goods_style']) ? json_decode($data['goods_style'],true) : [];
        return array_sum(StyleValue::where('id','in',$goods_style)->column('style_value_price'));
    }
}