Goods.php 1.1 KB
<?php


namespace app\api\model;


use think\Model;

class Goods extends Model
{
    protected $name = 'litestore_goods';
    protected $append = [
        'image_text',
        'images_text',
        'down_image_text',
        'four_image_text'
    ];

    public function getImageTextAttr($value,$data)
    {
        $value = !empty($data['image']) ? cdnurl($data['image'],true):'';
        return $value;
    }

    public function getFourImageTextAttr($value,$data)
    {
        $value = !empty($data['four_image']) ? explode(',',$data['four_image']):[];
        foreach ($value as $key => &$val){
            $val = cdnurl($val,true);
        }
        return $value;
    }

    public function getImagesTextAttr($value,$data)
    {
        $value = !empty($data['images']) ? explode(',',$data['images']):[];
        foreach ($value as $key => &$val){
            $val = cdnurl($val,true);
        }
        return $value;
    }

    public function getDownImageTextAttr($value,$data)
    {
        $value = !empty($data['down_image']) ? cdnurl($data['down_image'],true):'';
        return $value;
    }
}